def solve():
n = int(input())
a1 = list(map(str, input().split()))
a2 = list(map(str, input().split()))
a3 = list(map(str, input().split()))
a4 = a1 + a2 + a3
d = {}
c1 = 0
c2 = 0
c3 = 0
for i in range(n*3):
try:
d[a4[i]] = d[a4[i]] + 1
except:
d[a4[i]] = 1
for i in range(n):
if d[a1[i]]==1:
c1+=3
elif d[a1[i]]==2:
c1+=1
for i in range(n):
if d[a2[i]]==1:
c2+=3
elif d[a2[i]]==2:
c2+=1
for i in range(n):
if d[a3[i]]==1:
c3+=3
elif d[a3[i]]==2:
c3+=1
print(str(c1) + " " + str(c2) + " " + str(c3))
if __name__ == '__main__':
t = int(input())
for i in range(t):
solve()
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
#define H unsigned long long
#define V vector<int>
#define M vector<vector<int>>
#define ld long double
#define C complex<ld>
#define X real()
#define Y imag()
using namespace std;
const long double PI = acos(-1);
const int MAXN = 2 * 1e5;
const int MOD = 1e9 + 7;
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
while (t --) {
int n; cin >> n;
vector<vector<string>> v(n, vector<string> (3));
map<string, int> m;
for (int i = 0; i < 3; i ++) {
for (int j = 0; j < n; j ++) {
cin >> v[j][i];
m[v[j][i]] ++;
}
}
int a = 0, b = 0, c = 0;
for (int i = 0; i < n; i ++) {
string an = v[i][0];
int cnt = m[an];
if (cnt == 1) {
a += 3;
} else if (cnt == 2) {
a ++;
}
}
for (int i = 0; i < n; i ++) {
string an = v[i][1];
int cnt = m[an];
if (cnt == 1) {
b += 3;
} else if (cnt == 2) {
b ++;
}
}
for (int i = 0; i < n; i ++) {
string an = v[i][2];
int cnt = m[an];
if (cnt == 1) {
c += 3;
} else if (cnt == 2) {
c ++;
}
}
cout << a << " " << b << " " << c << "\n";
}
return 0;
}
1605B - Reverse Sort | 1607C - Minimum Extraction |
1604B - XOR Specia-LIS-t | 1606B - Update Files |
1598B - Groups | 1602B - Divine Array |
1594B - Special Numbers | 1614A - Divan and a Store |
2085. Count Common Words With One Occurrence | 2089. Find Target Indices After Sorting Array |
2090. K Radius Subarray Averages | 2091. Removing Minimum and Maximum From Array |
6. Zigzag Conversion | 1612B - Special Permutation |
1481. Least Number of Unique Integers after K Removals | 1035. Uncrossed Lines |
328. Odd Even Linked List | 1219. Path with Maximum Gold |
1268. Search Suggestions System | 841. Keys and Rooms |
152. Maximum Product Subarray | 337. House Robber III |
869. Reordered Power of 2 | 1593C - Save More Mice |
1217. Minimum Cost to Move Chips to The Same Position | 347. Top K Frequent Elements |
1503. Last Moment Before All Ants Fall Out of a Plank | 430. Flatten a Multilevel Doubly Linked List |
1290. Convert Binary Number in a Linked List to Integer | 1525. Number of Good Ways to Split a String |