I couldn’t realize the parity, and solved only the small.

## solution

parity. frequency. $O(N \times N)$, linear time for the number of elements of the matrix.

Count the frequency of integers in the given vectors. Almost all integers are counted twice, in the row vector and in the column vector. But integers in the removed vector are counted twice. So you should collect the integers which appears odd-times.

## implementation

#!/usr/bin/env python3
for t in range(int(input())):
n = int(input())
cnt = {}
for y in range(2*n-1):
xs = list(map(int,input().split()))
for x in xs:
cnt[x] = (x in cnt and cnt[x] or 0) + 1
ans = []
for x in cnt:
if cnt[x] % 2 == 1:
ans.append(x)
ans.sort()
print('Case #{}: {}'.format(t+1, ' '.join(map(str,ans))))