Read problems statements in Mandarin Chinese and Russian as well. 

	A version control system(VCS) is a repository of files, often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change.

	Version control systems are essential for any form of distributed, collaborative development. Whether it is the history of a wiki page or large software development project, the ability to track each change as it was made, and to reverse changes when necessary can make all the difference between a well managed and controlled process and an uncontrolled ‘first come, first served’ system. It can also serve as a mechanism for due diligence for software projects.

	In this problem we'll consider a simplified model of a development project. Let's suppose, that there are N source files in the project. All the source files are distinct and numbered from 1 to N. 

	A VCS, that is used for maintaining the project, contains two sequences of source files. The first sequence contains the source files, that are ignored by the VCS. If a source file is not in the first sequence, then it's considered to be unignored. The second sequence contains the source files, that are tracked by the VCS. If a source file is not in the second sequence, then it's considered to be untracked. A source file can either be or not be in any of these two sequences.

	Your task is to calculate two values: the number of source files of the project, that are both tracked and ignored, and the number of source files of the project, that are both untracked and unignored.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of the test case description contains three integers N, M and K denoting the number of source files in the project, the number of ignored source files and the number of tracked source files.

The second line contains M distinct integers denoting the sequence A of ignored source files. The sequence is strictly increasing.

The third line contains K distinct integers denoting the sequence B of tracked source files. The sequence is strictly increasing.

------ Output ------ 

For each test case, output a single line containing two integers: the number of the source files, that are both tracked and ignored, and the number of the source files, that are both untracked and unignored.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ M, K ≤ N ≤ 100$
$1 ≤ A_{1} < A_{2} < ... < A_{M} ≤ N$
$1 ≤ B_{1} < B_{2} < ... < B_{K} ≤ N$

----- Sample Input 1 ------ 
2

7 4 6

1 4 6 7

1 2 3 4 6 7

4 2 2

1 4

3 4
----- Sample Output 1 ------ 
4 1

1 1
----- explanation 1 ------ 

	In the first test case, the source files {1, 4, 6, 7} are both tracked and ignored, the source file {5} is both untracked and unignored.

	In the second test case, the source file {4} is both tracked and ignored, the source file {2} is both untracked and unignored.

Source: codechef | Difficulty: EASY
Tags: Data structures

Mathematics


Solutions:
for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(count1, count2) = (0, 0)
	for i in a:
		if i in b:
			count1 += 1
	for i in range(1, n + 1):
		if i not in a and i not in b:
			count2 += 1
	print(count1, count2)


import array as arr
t = int(input())
for q in range(t):
	(n, m, k) = [int(n) for n in input().split()]
	A = list(map(int, input().strip().split()))[:m]
	B = list(map(int, input().strip().split()))[:k]
	a = arr.array('i', A)
	b = arr.array('i', B)
	count1 = 0
	count2 = 0
	count3 = 0
	for i in a:
		if i in b:
			count1 += 1
	for i in a:
		if i not in b:
			count2 += 1
	for i in b:
		if i not in a:
			count3 += 1
	print(count1, n - (count1 + count2 + count3))


t = int(input())
while t > 0:
	(n, m, k) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a & b
	d = a | b
	print(len(c), n - len(d))
	t = t - 1


for _ in range(int(input())):
	(N, M, K) = list(map(int, input().split()))
	M = list(map(int, input().split()))
	K = list(map(int, input().split()))
	un_tra_ign = []
	v = list(set(M + K))
	for i in range(1, N + 1):
		if i not in v:
			un_tra_ign.append(i)
	track_ign = list(set(M) & set(K))
	print(len(track_ign), len(un_tra_ign))


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	trk = set(map(int, input().split()))
	ign = set(map(int, input().split()))
	ti = len(trk & ign)
	uu = n - len(trk | ign)
	print(ti, uu)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	ignored = list(map(int, input().split()))
	tracked = list(map(int, input().split()))
	count1 = 0
	count2 = 0
	for i in ignored:
		if i in tracked:
			count1 += 1
	for j in range(1, n + 1):
		if j not in ignored and j not in tracked:
			count2 += 1
	print(count1, count2)


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	s = 0
	for i in range(1, n + 1):
		if i in a and i in b:
			f = f + 1
		elif i not in a and i not in b:
			s = s + 1
	print(f, s)


t = int(input())
for tc in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	d = 0
	for j in range(1, n + 1):
		if j in a and j in b:
			c += 1
		elif j not in a and j not in b:
			d += 1
	print(c, d)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c1, c2) = (0, 0)
	for i in range(1, n + 1):
		if i in a and i in b:
			c1 += 1
		if i not in a and i not in b:
			c2 += 1
	print(c1, c2)


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = c1 = 0
	for i in range(1, n + 1):
		if i in a and i in b:
			c += 1
		elif i not in a and i not in b:
			c1 += 1
	print(str(c) + ' ' + str(c1))


for i in range(int(input())):
	(n, m, k) = [int(i) for i in input().split()]
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	c = ''
	f1 = 0
	for i in l1:
		if i in l2:
			f1 += 1
	c += str(f1)
	f = 0
	for i in range(1, n + 1):
		if i not in l1 and i not in l2:
			f += 1
	c += ' '
	c += str(f)
	print(c)


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	first = 0
	second = 0
	for i in range(1, n + 1):
		if i in a and i in b:
			first += 1
		elif i not in a and i not in b:
			second += 1
	print(str(first) + ' ' + str(second))


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = [0 for j in range(n + 1)]
	for j in a:
		f[j] += 1
	for j in b:
		f[j] += 1
	c = d = 0
	for j in f:
		if j == 2:
			c += 1
		if j == 0:
			d += 1
	print(c, d - 1)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split(' '))
	ignored_sources = list(map(int, input().split(' ')))
	tracked_sources = list(map(int, input().split(' ')))
	(tracked_ignored, untracked_unignored) = (0, 0)
	for i in range(1, n + 1):
		if i in ignored_sources and i in tracked_sources:
			tracked_ignored += 1
		elif i not in ignored_sources and i not in tracked_sources:
			untracked_unignored += 1
	print(str(tracked_ignored) + ' ' + str(untracked_unignored))


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	ignored = set(map(int, input().split()))
	tracked = set(map(int, input().split()))
	print(len(ignored & tracked), n - len(ignored | tracked))


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	z = a.intersection(b)
	j = 1
	k = 0
	o = ' '
	for i in range(n):
		if j not in a and j not in b:
			k = k + 1
		j = j + 1
	p = len(z)
	print(p, o, k)


b = int(input())
for i in range(b):
	a = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	k = 0
	l = 0
	for i in range(1, a[0] + 1):
		if i in c:
			if i in d:
				k = k + 1
		elif i not in d:
			l = l + 1
	print(k, l)


for x in range(int(input())):
	(N, M, K) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	(a, b) = (0, 0)
	for i in range(1, N + 1):
		if i in s1 and i in s2:
			a += 1
		elif i not in s1 and i not in s2:
			b += 1
	print(a, b)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	first = 0
	sceond = 0
	for i in range(1, a + 1):
		if i in d and i in e:
			first += 1
		elif i not in d and i not in e:
			sceond += 1
	print(first, sceond)


n = int(input())
for _ in range(n):
	f = input().split()
	ignored = input().split()
	traked = input().split()
	tig = 0
	utuig = 0
	if int(f[1]) <= int(f[2]):
		for i in ignored:
			if i in traked:
				tig = tig + 1
			else:
				utuig = utuig - 1
		utuig = utuig + int(f[0]) - int(f[2])
	else:
		for i in traked:
			if i in ignored:
				tig = tig + 1
			else:
				utuig = utuig - 1
		utuig = utuig + int(f[0]) - int(f[1])
	print(tig, utuig)


for _ in range(int(input())):
	(N, K, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	n1 = 0
	n2 = 0
	l1 = len(A)
	l2 = len(B)
	if l1 > l2:
		for j in range(1, N + 1):
			if j not in A and j not in B:
				n2 += 1
	else:
		for j in range(1, N + 1):
			if j not in A and j not in B:
				n2 += 1
	if l1 > l2:
		for i in range(0, l1):
			if A[i] in B:
				n1 += 1
	else:
		for i in range(0, l2):
			if B[i] in A:
				n1 += 1
	print(str(n1) + ' ' + str(n2))


def intersect(lst_1, lst_2):
	return len(set(lst_1) & set(lst_2))

def unite(n, lst_1, lst_2):
	return n - len(set(lst_1) | set(lst_2))
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	ignored = list(map(int, input().split()))
	tracked = list(map(int, input().split()))
	print(intersect(ignored, tracked), unite(n, ignored, tracked))


t = int(input())
for i in range(t):
	set_m = set()
	(n, m, k) = map(int, input().split())
	set_m.update(range(1, n + 1))
	i = set(map(int, input().split()))
	t = set(map(int, input().split()))
	set_a = i.intersection(t)
	a = set_m - i
	b = set_m - t
	set_b = a.intersection(b)
	print(len(set_a), len(set_b))


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	l = [0, 0]
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for i in range(1, n + 1):
		if i in l1 and i in l2:
			l[0] = l[0] + 1
		elif i not in l1 and i not in l2:
			l[1] = l[1] + 1
	print(*l)


for _ in range(int(input())):
	tg = 0
	utg = 0
	(f, g, h) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for k in range(1, f + 1):
		if k in a and k in b:
			tg += 1
		elif k not in a and k not in b:
			utg += 1
	print(tg, utg)


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	p = [i for i in range(1, n + 1)]
	c = 0
	o = 0
	for i in l:
		if i in m:
			c += 1
	for i in p:
		if i not in l and i not in m:
			o += 1
	print(c, o, sep=' ')


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	l = []
	for i in range(1, n + 1):
		l.append(i)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(cnt, cnt1) = (0, 0)
	for i in a:
		if i in b:
			cnt += 1
	for i in l:
		if i not in a and i not in b:
			cnt1 += 1
	print(cnt, cnt1)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	aIgnored = list(map(int, input().split()))
	bTracked = list(map(int, input().split()))
	flag1 = 0
	flag2 = 0
	for j in range(1, n + 1):
		if j in aIgnored and j in bTracked:
			flag1 += 1
		elif j not in aIgnored and j not in bTracked:
			flag2 += 1
	print(flag1, flag2)


buddy = int(input())
for i in range(buddy):
	(janu, cute, pie) = map(int, input().split())
	vi = list(map(int, input().split()))
	jay = list(map(int, input().split()))
	first = 0
	second = 0
	for i in range(1, janu + 1):
		if i in vi and i in jay:
			first += 1
		elif i not in vi and i not in jay:
			second += 1
	print(str(first) + ' ' + str(second))


for i in range(int(input())):
	(n, ig, t) = map(int, input().split())
	ig1 = set(map(int, input().split()))
	t1 = set(map(int, input().split()))
	print(len(ig1.intersection(t1)), end=' ')
	print(n - (ig + t - len(ig1.intersection(t1))))


for _ in range(int(input())):
	(n, k, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = 0
	b = 0
	for i in range(1, n + 1):
		if i in l1 and i in l2:
			a = a + 1
		if i not in l1 and i not in l2:
			b = b + 1
	print(a, b)


t = int(input())
for i in range(t):
	(m, k, n) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	count = [0] * m
	for i in range(k):
		count[A[i] - 1] += 1
	for i in range(n):
		count[B[i] - 1] += 1
	res1 = 0
	res2 = 0
	for i in range(m):
		if count[i] > 1:
			res1 += 1
		if count[i] == 0:
			res2 += 1
	print(res1, res2)


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = []
	l4 = []
	for i in range(1, n + 1):
		if i not in l1 and i not in l2:
			l3.append(i)
		if i in l1 and i in l2:
			l4.append(i)
	print(len(l4), end=' ')
	print(len(l3))


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	m_li = list(map(int, input().split()))
	k_li = list(map(int, input().split()))
	count1 = 0
	count2 = 0
	for i in range(1, n + 1):
		if i in m_li and i in k_li:
			count1 += 1
		if i not in m_li and i not in k_li:
			count2 += 1
	print(count1, count2)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split(' '))
	arr_a = list(map(int, input().split(' ')))
	arr_b = list(map(int, input().split(' ')))
	a_set = set(arr_a)
	b_set = set(arr_b)
	total = [i for i in range(1, a + 1)]
	common_list = len(a_set.intersection(b_set))
	complete_list = list(set(arr_a + arr_b))
	rem = len(set(total) - set(complete_list))
	print(str(common_list) + ' ' + str(rem))


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	ignored = list(map(int, input().split()))
	tracked = list(map(int, input().split()))
	print(len(set(ignored) & set(tracked)), end=' ')
	print(len(set(range(1, n + 1)).symmetric_difference(ignored + tracked)))


t = int(input())
for _ in range(t):
	(n, m, k) = [int(x) for x in input().split()]
	ignored = [int(x) for x in input().split()]
	tracked = [int(x) for x in input().split()]
	(i, j, c1, c2) = (0, 0, 0, 0)
	while i < m and j < k:
		if ignored[i] == tracked[j]:
			c1 += 1
			i += 1
			j += 1
		elif ignored[i] > tracked[j]:
			j += 1
		else:
			i += 1
	c2 = n - (m + k - c1)
	print(str(c1) + ' ' + str(c2))


a = int(input())
for i in range(1, a + 1):
	new = []
	str = ''
	(p, q, r) = map(int, input().split())
	m = list(map(int, input().split()))
	n = list(map(int, input().split()))
	s = set(m)
	m.extend(n)
	b = set(m)
	t = set(n)
	king = s & t
	king = len(king)
	for i in range(1, p + 1):
		new.append(i)
	new = set(new)
	raj = new - b
	raj = len(raj)
	print(king, raj)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(y) for y in input().split()]
	q1 = len(set(a) & set(b))
	q2 = n - len(set(a) | set(b))
	print(q1, q2)


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	t = 0
	for j in range(1, n + 1):
		if a.count(j) == b.count(j) and a.count(j) == 1:
			i += 1
		elif a.count(j) == b.count(j) and a.count(j) == 0:
			t += 1
	else:
		print(str(i) + ' ' + str(t))


n = int(input())
for k in range(n):
	s = list(map(int, input().split()))
	i = list(map(int, input().split()))
	t = list(map(int, input().split()))
	l = list(set(i) & set(t))
	TnI = len(l)
	p = []
	for j in range(1, s[0] + 1):
		if j not in i and j not in t:
			p.append(i)
	nTnI = len(p)
	print(str(TnI) + ' ' + str(nTnI))


T = int(input())
for i in range(T):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	count_t_i = 0
	count_ut_ui = 0
	for i in range(1, N + 1):
		if i in A and i in B:
			count_t_i += 1
		if i not in A and i not in B:
			count_ut_ui += 1
	print(count_t_i, ' ', count_ut_ui)


for _ in range(int(input())):
	(N, M, K) = map(int, input().split())
	Ignored = list(map(int, input().split()))
	tracked = list(map(int, input().split()))
	(TrIg, Un) = (0, 0)
	for i in range(1, N + 1):
		if i in tracked and i in Ignored:
			TrIg += 1
		elif i not in Ignored and i not in tracked:
			Un += 1
	print(TrIg, Un)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = 0
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				c += 1
				break
	for i in a:
		if i not in b:
			b.append(i)
	k = n - len(b)
	print(c, k)


T = int(input())
for i in range(T):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	a = 0
	b = 0
	for i in range(1, N + 1):
		if i in A and i in B:
			a += 1
		elif i not in A and i not in B:
			b += 1
	print(a, b)


for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	M = [int(x) for x in input().split()]
	K = [int(y) for y in input().split()]
	count = 0
	notcount = 0
	for z in range(1, n + 1):
		if z in M and z in K:
			count += 1
		elif z not in M and z not in K:
			notcount += 1
	print(count, notcount)


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = {j + 1 for j in range(n)}
	l1 = set(map(int, input().split()))
	l2 = set(map(int, input().split()))
	x = len(l1.intersection(l2))
	y = len(l.difference(l1.union(l2)))
	print(str(x) + ' ' + str(y))


for i in range(int(input())):
	(m, k, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t_f = [j for j in range(1, m + 1)]
	ignd = []
	trk = []
	unignd = []
	untrk = []
	for j in range(len(t_f)):
		if t_f[j] not in a:
			unignd.append(t_f[j])
		else:
			ignd.append(t_f[j])
		if t_f[j] not in b:
			untrk.append(t_f[j])
		else:
			trk.append(t_f[j])
	union = list(set(ignd) & set(trk))
	inter = list(set(unignd) & set(untrk))
	print(len(union), len(inter))


for _ in range(int(input())):
	ti = 0
	utui = 0
	(n, m, k) = map(int, input().split())
	sf1 = list(map(int, input().split()))
	sf2 = list(map(int, input().split()))
	for i in range(1, n + 1):
		if i in sf1 and i in sf2:
			ti = ti + 1
		if i not in sf1 and i not in sf2:
			utui = utui + 1
	print(ti, utui)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = set(a + b)
	ans1 = set(a) & set(b)
	count = 0
	for i in range(1, n + 1):
		if i not in arr:
			count += 1
	ans2 = count
	print(len(ans1), ans2)


t = int(input())
for i in range(0, t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = [i for i in range(1, n + 1)]
	cn = 0
	r = 0
	for i in a:
		if i in b:
			cn += 1
	for i in k:
		if i not in a and i not in b:
			r += 1
	print(cn, r, sep=' ')


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	fst = 0
	scd = 0
	for i in range(1, n + 1):
		if i in a and i in b:
			fst += 1
		if i not in a and i not in b:
			scd += 1
	print(str(fst) + ' ' + str(scd))


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	ignore = list(map(int, input().split()))
	tracked = list(map(int, input().split()))
	ignore_tracked = 0
	unignore_untracked = 0
	for i in range(1, n + 1):
		if i in ignore and i in tracked:
			ignore_tracked += 1
		elif i not in ignore and i not in tracked:
			unignore_untracked += 1
	print(ignore_tracked, unignore_untracked)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	ignored = {int(num) for num in input().split()}
	tracked = {int(num) for num in input().split()}
	ti = len(ignored & tracked)
	utui = len(set(range(1, n + 1)) - (ignored | tracked))
	print(f'{ti} {utui}')


t = int(input())
for i in range(t):
	n_m_k = input().split(' ')
	a = input().split(' ')
	b = input().split(' ')
	(t_i, u_u) = (0, 0)
	for j in range(1, int(n_m_k[0]) + 1):
		if str(j) in a and str(j) in b:
			t_i += 1
		elif str(j) not in a and str(j) not in b:
			u_u += 1
	print(t_i, u_u)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	(count_1, count_2) = (0, 0)
	for i in A:
		for j in B:
			if i == j:
				count_1 += 1
	for i in range(1, n + 1):
		if i not in A and i not in B:
			count_2 += 1
	print(count_1, count_2)


t = int(input())
while t:
	(N, M, K) = map(int, input().split())
	ti = 0
	uu = 0
	A = input().split()
	B = input().split()
	for j in range(1, N + 1):
		if str(j) not in A and str(j) not in B:
			ti += 1
		if str(j) in A and str(j) in B:
			uu += 1
	print(uu, ti)
	t = t - 1


c = int(input())
for i in range(c):
	l1 = input().split(' ')
	n = int(l1[0])
	igc = int(l1[1])
	trc = int(l1[2])
	ig = input().split(' ')
	tr = input().split(' ')
	ls = [tr, ig]
	ig_tr = 0
	if igc > trc:
		ls = [ig, tr]
	j = 0
	for i in ls[1]:
		while j < len(ls[0]):
			if int(ls[0][j]) > int(i):
				break
			if int(ls[0][j]) == int(i):
				ig_tr += 1
			j += 1
	uig_utr = n - (igc + trc - ig_tr)
	print(ig_tr, uig_utr)


a = int(input())
for i in range(a):
	b = list(map(int, input().split()))
	c = set(map(int, input().split()))
	d = set(map(int, input().split()))
	e = set(range(1, b[0] + 1))
	print(len(c.intersection(d)), len(e - c.union(d)), sep=' ')


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	ls = [x for x in range(1, n + 1)]
	(c1, c2) = (0, 0)
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	for i in ls:
		if i in s1 and i in s2:
			c1 += 1
		if i not in s1 and i not in s2:
			c2 += 1
	print(c1, c2)


T = int(input())
for i in range(T):
	numbers = [int(n) for n in input().split()]
	N = [int(i) for i in range(1, numbers[0] + 1)]
	M = [int(m) for m in input().split()]
	K = [int(k) for k in input().split()]
	count = 0
	igno = 0
	for i in N:
		if i in M and i in K:
			count = count + 1
		if i not in M and i not in K:
			igno = igno + 1
	print(count, igno)


for _ in range(int(input())):
	(N, I, T) = map(int, input().split())
	Li = list(map(int, input().split()))
	Lt = list(map(int, input().split()))
	c1 = 0
	c2 = 0
	for i in range(1, N + 1):
		if i in Li and i in Lt:
			c1 += 1
		elif i not in Li and i not in Lt:
			c2 += 1
	print(c1, c2)