Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.

During his ride, Arkady woke up several times and each time he saw the tram stopping at some stop. For each stop he knows which lines of tram stop there. Given this information, can you help Arkady determine what are the possible lines of the tram he was in?


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 100$) — the number of stops Arkady saw.

The next $n$ lines describe the stops. Each of them starts with a single integer $r$ ($1 \le r \le 100$) — the number of tram lines that stop there. $r$ distinct integers follow, each one between $1$ and $100$, inclusive, — the line numbers. They can be in arbitrary order.

It is guaranteed that Arkady's information is consistent, i.e. there is at least one tram line that Arkady could take.


-----Output-----

Print all tram lines that Arkady could be in, in arbitrary order.


-----Examples-----
Input
3
3 1 4 6
2 1 4
5 10 5 6 4 1

Output
1 4 

Input
5
1 1
10 10 9 8 7 100 5 4 3 99 1
5 1 2 3 4 5
5 4 1 3 2 5
4 10 1 5 3

Output
1 



-----Note-----

Consider the first example. Arkady woke up three times. The first time he saw a stop with lines $1$, $4$, $6$. The second time he saw a stop with lines $1$, $4$. The third time he saw a stop with lines $10$, $5$, $6$, $4$ and $1$. He can be in a tram of one of two lines: $1$ or $4$.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
n = int(input())
r = []
for i in range(n):
	r.append(input().split())
k = r[0][1:]
for j in range(len(r) - 1):
	k = list(set(k) & set(r[j + 1][1:]))
for item in k:
	print(item, end=' ')


from collections import Counter
n = int(input())
a = Counter()
for i in range(n):
	st = list(map(int, input().split()))
	for k in st[1:]:
		a[k] += 1
list = []
for i in a.keys():
	if a[i] == n:
		list += [str(i)]
print(' '.join(list))


s = set(range(101))
for _ in [0] * int(input()):
	s &= set([*map(int, input().split())][1:])
print(*s)


n = int(input())
S = [int(x) for x in input().split()][1:]
D = []
for i in S:
	if not i in D:
		D.append(i)
for i in range(0, n - 1):
	temp = []
	L = [int(x) for x in input().split()][1:]
	for i in D:
		if i in L:
			if not i in temp:
				temp.append(i)
	D = temp
print(' '.join([str(x) for x in D]))


import math

def main():
	n = int(input())
	tab = []
	for x in range(n):
		i = list(map(int, input().split()))
		i.pop(0)
		tab.append(i)
	for x in range(1, 101):
		inc = 0
		for y in range(n):
			if x in tab[y]:
				inc += 1
		if inc == n:
			print(x, end=' ')
	print()
main()


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
n = int(stdin.readline())
used = [0 for i in range(101)]
for i in range(n):
	for v in map(int, stdin.readline().split()[1:]):
		used[v] += 1
for i in range(1, 101):
	if used[i] == n:
		stdout.write(str(i) + ' ')


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
s = set(li()[1:])
for i in range(n - 1):
	s = s & set(li()[1:])
print(*s)


n = int(input())
new_set = set(tuple(map(int, input().split()))[1:])
for i in range(n - 1):
	new_set = new_set.intersection(set(tuple(map(int, input().split()))[1:]))
print(*new_set)


x = int(input())
listafinal = list(map(int, input().split()))
listafinal.pop(0)
listafinal = set(listafinal)
for c in range(x - 1):
	lista = list(map(int, input().split()))
	y = lista[0]
	lista.pop(0)
	lista = set(lista)
	listafinal = listafinal.intersection(lista)
msg = ''
listafinal = list(listafinal)
for c in listafinal:
	msg += str(c) + ' '
print(msg.strip())


n = int(input())
data = map(int, input().split())
next(data)
data = set(data)
for _ in range(n - 1):
	data2 = map(int, input().split())
	next(data2)
	data = data & set(data2)
print(' '.join(map(str, data)))


n = int(input())
possibles = set((int(s) for s in input().split()[1:]))
for i in range(n - 1):
	new = set((int(s) for s in input().split()[1:]))
	possibles = set.intersection(possibles, new)
print(*possibles)


n = int(input())
ans = [int(s) for s in input().split()][1:]
for i in range(1, n):
	a = [int(s) for s in input().split()][1:]
	newans = []
	for ai in a:
		if ai in ans:
			newans.append(ai)
	ans = newans
print(*newans)


n = int(input())
rs = [0] * 105
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		rs[a[j]] += 1
for i in range(len(rs)):
	if rs[i] == n:
		print(i)


n = int(input())
r = set(list(map(int, input().split()))[1:])
for i in range(1, n):
	a = set(list(map(int, input().split()))[1:])
	r = r & a
print(*r)


n = int(input())
p = []
p1 = []
for i in range(n):
	l = list(map(int, input().split()))
	p1.append(l[0])
	l.pop(0)
	p.append(l)
b = p1.index(min(p1))
c = p[b]
p.pop(b)
for i in range(min(p1)):
	for j in range(n - 1):
		if c[i] in p[j]:
			continue
		else:
			break
	else:
		print(c[i], end=' ')


n = int(input())
rs = set([int(i + 1) for i in range(100)])
for i in range(n):
	kek = [int(j) for j in input().split()]
	buf = set(kek[1:])
	rs = rs.intersection(buf)
print(*rs)


def sda(d, c):
	d.setdefault(c, 0)
	d[c] += 1
dt = {}
n = int(input())
for c in range(n):
	vt = input().split()
	for d in vt[1:]:
		sda(dt, d)
vk = [k for (k, v) in dt.items() if v == n]
print(' '.join(vk))


n = int(input())
ts = set(range(1, 101))
for i in range(n):
	s = [int(x) for x in input().split()]
	ts = ts & set(s[1:])
print(*ts)


gi = lambda : list(map(int, input().split()))
(n,) = gi()
ans = set(gi()[1:])
for k in range(n - 1):
	ans = ans.intersection(set(gi()[1:]))
print(' '.join(map(str, ans)))


n = int(input())
ans = set(list(map(int, input().split()))[1:])
for i in range(1, n):
	y = set(list(map(int, input().split()))[1:])
	ans = ans & y
print(*ans)


n = int(input())
s = [0] * 102
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, a[0] + 1):
		s[a[j]] += 1
for i in range(101):
	if s[i] == n:
		print(i, end=' ')


a = [repr(set(list(map(int, input().split()))[1:])) for i in range(int(input()))]
print(*eval('&'.join(a)))


n = int(input())
cnt = [0] * 100
for _ in range(n):
	first = True
	for i in list(map(int, input().split(' '))):
		if first:
			first = False
		else:
			cnt[i - 1] = cnt[i - 1] + 1
mx = max(cnt)
res = []
for i in range(len(cnt)):
	if mx == cnt[i]:
		res.append(i + 1)
print(*res)


n = int(input())
(_, *s) = map(int, input().split())
s = set(s)
for i in range(n - 1):
	(_, *s2) = map(int, input().split())
	s &= set(s2)
for x in s:
	print(x, end=' ')


N = int(input())
for i in range(N):
	lines = list(map(str, input().split()))
	lines = lines[1:]
	if i == 0:
		res = set(lines)
	else:
		res &= set(lines)
print(' '.join(res))


n = int(input())
hash = [0] * 101
a = [int(x) for x in input().split()]
a.pop(0)
ans = a.copy()
for i in range(1, n):
	a = list(ans)
	b = [int(x) for x in input().split()]
	ans.clear()
	b.pop(0)
	for j in range(len(b)):
		for k in range(len(a)):
			if a[k] == b[j]:
				ans.append(a[k])
for i in range(len(ans)):
	print(ans[i], end=' ')


n = int(input())
tram = [0 for i in range(102)]
for i in range(n):
	arr = list(map(int, input().split()))
	k = arr[0]
	for j in range(1, len(arr)):
		tram[arr[j]] += 1
for i in range(102):
	if tram[i] == n:
		print(i, end=' ')


Input = lambda : map(int, input().split())
n = int(input())
M = list(Input())
M.pop(0)
M = set(M)
for i in range(n - 1):
	Line = list(Input())
	Line.pop(0)
	Line = set(Line)
	M = Line.intersection(M)
print(*M)


from collections import Counter
lst = []
for i in range(int(input())):
	temp = list(map(int, input().split()))
	lst.extend(temp[1:])
dct = Counter(lst)
print(*[k for (k, v) in dct.items() if v >= i + 1])


set_ = {i for i in range(200)}
n = int(input())
for _ in range(n):
	l = list(map(int, input().split()))
	set_ = set_ & set(l[1:])
print(*set_)


n = int(input())
l = [[int(i) for i in input().split()] for i in range(n)]
f = []
for i in l[0][1:]:
	m = [i for j in range(1, n) if i in l[j][1:]]
	if len(m) == n - 1:
		f += m
for i in set(f):
	print(i, end=' ')


x = int(input())
maybe = list(map(int, input().split()))
maybe = maybe[1:]
maybe.sort()
listik1 = []
for i in range(x - 1):
	listik1 = list(map(int, input().split()))
	takeit = listik1[0]
	listik1 = listik1[1:]
	listik1.sort()
	j = 0
	while j < len(maybe):
		if maybe[j] not in listik1:
			maybe.remove(maybe[j])
		else:
			j += 1
	if len(maybe) == 1:
		break
print(*maybe)


b = []
for i in range(int(input())):
	l = list(map(int, input().split()))
	b.append(l[1:])
res = set(b[0])
for i in b[1:]:
	res.intersection_update(i)
lines = list(res)
for i in lines:
	print(i, end=' ')


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
d = [0] * 100000
for x in range(n):
	a = input().split()
	for y in a[1:]:
		d[int(y)] += 1
for x in range(10000):
	if d[x] == n:
		print(x, end=' ')


t = int(input())
arr = []
for i in range(t):
	arr2 = []
	for j in range(101):
		arr2.append(0)
	arr.append(arr2)
for i in range(t):
	arr3 = [int(x) for x in input().split()]
	for j in range(1, len(arr3)):
		arr[i][arr3[j]] = 1
for j in range(101):
	co = 0
	for i in range(t):
		if arr[i][j] == 1:
			co += 1
	if co == t:
		print(j, end=' ')


s = set([i for i in range(1, 101)])
n = int(input())
for j in range(n):
	t = set()
	a = [int(i) for i in input().split()]
	for i in range(1, len(a)):
		t.add(a[i])
	s = s.intersection(t)
print(*s)


n = int(input())
x = set(input().split()[1:])
for _ in range(n - 1):
	x &= set(input().split()[1:])
print(' '.join(x))


n = int(input())
ans = []
for i in range(n):
	s = list(map(int, input().split()))
	s = s[1:]
	s = set(s)
	ans.append(s)
res = ans[0]
for i in range(1, len(ans)):
	res = ans[i].intersection(res)
res = list(res)
print(*res)


n = int(input())
b = list()
for i in range(n):
	b.extend(list(map(int, input().split()))[1:])
a = set(b)
for i in a:
	if b.count(i) == n:
		print(i, end=' ')


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
s = set([i for i in range(1, 101)])
t = int(input())
for tt in range(t):
	ss = set()
	a = list(map(int, sys.stdin.readline().split(' ')))
	for i in range(1, len(a)):
		ss.add(a[i])
	s = s.intersection(ss)
print(*s)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


n = int(input())
x = list(map(int, input().split()))
c = x[1:]
for _ in range(n - 1):
	x = list(map(int, input().split()))
	a = x[1:]
	r = []
	for i in a:
		if i in c:
			r.append(i)
	c = r
print(*c)


n = int(input())
s = input().split()[1:]
s = set(s)
for i in range(n - 1):
	s1 = input().split()[1:]
	s1 = set(s1)
	s = s & s1
print(*list(s))


def intersection(*listas):
	return set(listas[0]).intersection(*listas[1:])
n = int(input())
arr = []
for _ in range(n):
	t = list(map(int, input().strip().split()))
	arr.append(t[1:])
ans = intersection(*arr)
print(*ans)


def user99():
	S = set([i for i in range(1, 100 + 1)])
	for _ in range(int(input())):
		line = list(map(int, input().split()))
		S = S & set(line[1:])
	for i in S:
		print(i, end=' ')
user99()


n = int(input())
ai = [1] * 101
ai[0] = 0
for i in range(n):
	ai2 = list(map(int, input().split()))
	ai3 = [0] * 101
	for i in range(1, ai2[0] + 1):
		ai3[ai2[i]] = 1
	for i in range(101):
		ai[i] = min(ai[i], ai3[i])
for i in range(101):
	if ai[i] == 1:
		print(i, end=' ')


n = int(input())
for i in range(n):
	(r, *a) = map(int, input().split())
	if i:
		ans &= set(a)
	else:
		ans = set(a)
print(*ans)


n = int(input())
lst = set(input().split()[1:])
for i in range(1, n):
	new_lst = set(input().split()[1:])
	lst.intersection_update(new_lst)
print(' '.join(list(lst)))


n = int(input())
d = {}
for i in range(n):
	s = input().split()
	for j in range(int(s[0])):
		d[s[j + 1]] = d.get(s[j + 1], 0) + 1
ans = ''
for x in d:
	if d[x] == n:
		ans += str(x) + ' '
print(ans.strip())


n = int(input())
(k, s, v) = ([], [], [])
for i in range(n):
	(a, *l) = list(map(int, input().split()))
	s += l
	k.append(l)
for i in k[0]:
	if s.count(i) == n:
		v.append(i)
print(*v)


from collections import Counter as c
x = int(input())
l = []
for i in range(x):
	l = l + list(map(int, input().split()))[1:]
l = dict(c(l))
for (a, b) in l.items():
	if b == x:
		print(a, end=' ')


n = int(input())
ls = []
for i in range(n):
	arr = [int(j) for j in input().split()]
	for j in range(1, len(arr)):
		ls.append(arr[j])
for j in range(1, 101):
	if ls.count(j) == n:
		print(j, end=' ')


n = int(input())
I = [int(x) for x in input().split()]
I = set(I[1:])
for i in range(1, n):
	a = [int(x) for x in input().split()]
	a = set(a[1:])
	I = I.intersection(a)
for j in I:
	print(j, end=' ')
print()


n = int(input())
a = set()
for i in range(101):
	a.add(i)
for i in range(n):
	b = list(map(int, input().split()))
	b.pop(0)
	b = set(b)
	a = a.intersection(b)
for i in a:
	print(i, end=' ')


n = int(input())
ans = set()
for i in range(n):
	if i == 0:
		li = list(map(int, input().split()))
		li.pop(0)
		ans.update(li)
	else:
		li = list(map(int, input().split()))
		li.pop(0)
		ans.intersection_update(li)
print(*ans)


lines = [0 for x in range(101)]
stops = int(input())
for rpt in range(stops):
	stop = [int(x) for x in input().split()]
	for i in range(1, stop[0] + 1):
		lines[stop[i]] += 1
res = ''
for i in range(101):
	if lines[i] == stops:
		res = res + str(i) + ' '
print(res)


n = int(input())
s = set(map(int, input().split()[1:]))
for i in range(n - 1):
	s = s.intersection(map(int, input().split()[1:]))
print(' '.join(map(str, s)))


n = int(input())
c = [0] * 200
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(1, len(a)):
		c[a[i]] += 1
for i in range(len(c)):
	if c[i] == n:
		print(i, end=' ')


from collections import Counter
cases = int(input())
x = cases
lst = []
while cases:
	cases -= 1
	arr = list(map(int, input().split()))[1:]
	lst.extend(arr)
frq = Counter(lst)
ans = []
for (key, val) in frq.items():
	if val == x:
		ans.append(key)
print(*ans)


n = int(input())
a = []
for i in range(n):
	a.append({int(x) for x in input().split()[1:]})
s = a[0]
for i in a:
	s = s.intersection(i)
for i in s:
	print(i, end=' ')


n = int(input())
stops = []

def joint(a, b):
	result = []
	for x in a:
		if x in b:
			result.append(x)
	return result
for m in range(n):
	arr = input().split()[1:]
	if len(stops) == 0:
		stops = arr
	else:
		stops = joint(stops, arr)
print(' '.join(stops))


def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]
T = int(input())
d = [0] * 101
for test in range(T):
	arr = read_ints()
	for i in range(1, len(arr)):
		el = arr[i]
		if d[el] != 0:
			d[el] += 1
		else:
			d[el] = 1
for (k, v) in enumerate(d):
	if v == T:
		print(k, end=' ')


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return list(map(int, sys.stdin.readline().strip().split()))

def charIN():
	return sys.stdin.readline().strip().split()
n = int(input())
x = [0] * 1000
for _ in range(n):
	l = list(numIN())
	for i in l[1:]:
		x[i] += 1
z = []
for i in range(1000):
	if x[i] == n:
		z.append(str(i))
print(' '.join(z))


n = int(input())
line = list(map(int, input().split()))
r = line[0]
variants = set(line[1:])
for i in range(1, n):
	line = list(map(int, input().split()))
	r = line[0]
	var = set(line[1:])
	variants.intersection_update(var)
for v in variants:
	print(v, end=' ')


n = int(input())
a = [int(s) for s in input().split()]
for i in range(1, n):
	b = []
	b = [int(v) for v in input().split()]
	for j in range(1, len(a)):
		if a[j] in b[1:]:
			pass
		else:
			a[j] = 1000
for j in range(1, len(a)):
	if a[j] != 1000:
		print(a[j], end=' ')


def ans(arr):
	i = 1
	a = arr[0]
	while i < n:
		b = arr[i]
		a = a.intersection(b)
		i += 1
	return sorted(list(a))
n = int(input())
temp = []
for _ in range(n):
	r = list(map(int, input().strip().split()))
	temp.append(set(r[1:]))
print(*ans(temp))


n = int(input())
d = dict()
for i in range(n):
	arr_num = input().split()
	for j in range(1, len(arr_num)):
		if j != 0:
			try:
				d[arr_num[j]] += 1
			except:
				d[arr_num[j]] = 1
for i in d:
	if d[i] == n:
		print(i, end=' ')


SS = int(input())
ans = set(list(map(int, input().split()))[1:])
for s in range(SS - 1):
	ans = ans.intersection(set(list(map(int, input().split()))[1:]))
for a in ans:
	print(a, end=' ')


n = int(input())
lines = [0 for _ in range(101)]
for _ in range(n):
	(l, *line) = list(map(int, input().strip().split()))
	for v in line:
		lines[v] += 1
maxv = 0
ans = []
for (index, line) in enumerate(lines):
	if line > maxv:
		ans = [index]
		maxv = line
	elif line == maxv:
		ans.append(index)
print(*ans)


n = int(input())
z = []
res = []
we = [i for i in range(101)]
set1 = set(we)
for i in range(n):
	l = list(map(int, input().split()))
	set2 = set(l[1:])
	x = l[0]
	set1 = set1.intersection(set2)
set1 = list(set1)
print(*set1)


t = int(input())
n = t
a = [[] for i in range(t)]
i = 0
while t:
	l = list(map(int, input().split()))
	a[i] = l[1:]
	a[i] = set(a[i])
	i += 1
	t -= 1
x = a[0]
for i in range(1, n):
	x = x.intersection(a[i])
for i in x:
	print(i, end=' ')
print()


n = int(input())
q = [int(i) for i in input().split()]
q = set(q[1:])
for i in range(n - 1):
	w = [int(j) for j in input().split()]
	w = set(w[1:])
	q = q & w
print(*q)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
a = set([i for i in range(1, 101)])
for i in range(n):
	b = mints()
	next(b)
	a &= set(b)
print(*list(a))


n = int(input())
v = []
for i in range(n):
	l = [int(x) for x in input().split()]
	v.append(l)
c = ''
for j in range(1, len(v[0])):
	m = 0
	for k in range(1, n):
		if v[0][j] in v[k][1:len(v[k])]:
			m += 1
	if m == n - 1:
		c += str(v[0][j])
		c += ' '
print(c)


n = int(input())
l = list(map(int, input().split()))
l = l[1:]
l = set(l)
for i in range(n - 1):
	m = list(map(int, input().split()))
	m = m[1:]
	m = set(m)
	l = l.intersection(m)
for i in l:
	print(i, end=' ')


from fractions import gcd
import math
from itertools import permutations
from itertools import combinations
import calendar
from itertools import product

def readInts():
	return list(map(int, raw_input().strip().split()))

def readInt():
	return int(raw_input())

def readStrs():
	return raw_input().split()

def readStr():
	return raw_input()

def readarr(n):
	return [map(int, list(readStr())) for i in xrange(n)]

def readnumbertolist():
	a = [int(i) for i in list(raw_input())]
	return a

def strlistTostr(list1):
	return ''.join(list1)

def numlistTostr(list1):
	return ''.join((str(e) for e in list1))

def strTolist(str):
	return str.split()

def strlistTointlist(str):
	return map(int, str)

def slicenum(number, x):
	return int(str(number)[:x])

def precise(num):
	return '{0:.10f}'.format(num)

def rsorted(a):
	return sorted(a, reverse=True)

def binar(x):
	return '{0:031b}'.format(x)

def findpermute(word):
	perms = [''.join(p) for p in permutations(word)]
	return set(perms)

def findsubsets(S, m):
	return set(itertools.combinations(S, m))

def sort1(yy, index):
	return yy.sort(key=lambda x: x[index])

def reversepair(yy):
	return yy[::-1]

def checkint(x):
	return x.is_integer()

def sum_digits(n):
	s = 0
	while n:
		s += n % 10
		n //= 10
	return s

def vowel_count(str):
	count = 0
	vowel = set('aeiouAEIOU')
	for alphabet in str:
		if alphabet in vowel:
			count = count + 1
	return count

def leapyear(year):
	return calendar.isleap(year)

def primes_sieve(limit):
	limitn = limit + 1
	not_prime = set()
	primes = []
	for i in range(2, limitn):
		if i in not_prime:
			continue
		for f in range(i * 2, limitn, i):
			not_prime.add(f)
		primes.append(i)
	return primes

def distinctstr(s):
	t = ''.join(set(s))
	return t

def countdict(s):
	d = {}
	for i in range(len(s)):
		if s[i] not in d.keys():
			d[s[i]] = 1
		else:
			d[s[i]] += 1
	return d
import operator as op

def nck(n, k):
	k = min(n - k, k)
	result = 1
	for i in range(1, k + 1):
		result = result * (n - i + 1) / i
	return result

def matrixcheck(x, y):
	faadu = []
	directions = zip((0, 0, 1, -1), (1, -1, 0, 0))
	for (dx, dy) in directions:
		if R > x + dx >= 0 <= y + dy < C and A[x + dx][y + dy] == 0:
			faadu.append((x + dx, y + dy))
	return faadu

def stringcount(s):
	return [s.count(i) for i in 'abcdefghijklmnopqrstuvwxyz']

def bubbleSort(arr):
	n = len(arr)
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j] > arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])

def isSubsetSum(st, n, sm):
	subset = [[True] * (sm + 1)] * (n + 1)
	for i in range(0, n + 1):
		subset[i][0] = True
	for i in range(1, sm + 1):
		subset[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, sm + 1):
			if j < st[i - 1]:
				subset[i][j] = subset[i - 1][j]
			if j >= st[i - 1]:
				subset[i][j] = subset[i - 1][j] or subset[i - 1][j - st[i - 1]]
	return subset[n][sm]

def decimal_to_octal(dec):
	decimal = int(dec)
	return oct(decimal)

def decimal_to_binary(dec):
	decimal = int(dec)
	return bin(decimal)

def decimal_to_hexadecimal(dec):
	decimal = int(dec)
	return hex(decimal)

def intersection(*listas):
	return set(listas[0]).intersection(*listas[1:])

def solve():
	n = int(input())
	arr = []
	for _ in range(n):
		t = list(map(int, input().strip().split()))
		arr.append(t[1:])
	ans = intersection(*arr)
	print(*ans)
solve()


import sys
import math
import bisect
import itertools
import random

def main():
	n = int(input())
	for i in range(n):
		if i == 0:
			s = set(map(int, input().split()[1:]))
		else:
			s &= set(map(int, input().split()[1:]))
	print(' '.join(list((str(a) for a in s))))
main()


def main_function():
	input_list = [[int(i) for i in input().split(' ')][1:] for h in range(int(input()))]
	output_list = []
	for i in range(len(input_list[0])):
		current_tram = input_list[0][i]
		should_tram_be_added = True
		for j in range(1, len(input_list)):
			is_tram_in_the_list = False
			for k in range(len(input_list[j])):
				if input_list[j][k] == current_tram:
					is_tram_in_the_list = True
					break
			if not is_tram_in_the_list:
				should_tram_be_added = False
				break
		if should_tram_be_added and (not str(current_tram) in output_list):
			output_list.append(str(current_tram))
	return ' '.join(output_list)
print(main_function())


n = int(input())
c = [0] * 101
for i in range(0, n):
	r = list(map(int, input().split()))
	for i in range(1, r[0] + 1):
		c[r[i]] += 1
for i in range(0, 101):
	if c[i] == n:
		print(i, end=' ')


a = int(input())
d = []
for i in range(a):
	b = list(map(int, input().split()))
	b.remove(b[0])
	for c in range(len(b)):
		d.append(b[c])
r = max(d)
z = []
e = d[:]
e.sort()
for v in range(r + 1):
	p = e.count(v)
	if p == a:
		z.append(v)
	else:
		continue
zx = list(map(str, z))
q = ' '.join(zx)
print(q)


def main():
	n = int(input())
	d = dict()
	for i in range(n):
		arr = list(map(int, input().split()))[1:]
		for j in arr:
			if j not in d:
				d[j] = 0
			d[j] += 1
	for t in d.keys():
		if d[t] == n:
			print(t, end=' ')
main()


n = int(input())
dict1 = {}
for i in range(n):
	arr = list(map(int, input().split()))
	for j in arr[1:]:
		try:
			dict1[j] += 1
		except:
			KeyError
			dict1[j] = 1
ansarr = []
for i in dict1.keys():
	if dict1[i] == n:
		ansarr.append(i)
print(*ansarr)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
from collections import defaultdict
lines = defaultdict(int)
nb_wakes = read_int()
for _ in range(nb_wakes):
	line = read_ints()
	for i in line[1:]:
		lines[i] += 1
	for (k, v) in lines.items():
		if v == nb_wakes:
			print(k, end=' ')


n = int(input())
main = [True] * 100
for _ in range(n):
	l = [int(x) for x in input().split()]
	l = l[1:]
	d = {}
	for i in l:
		d[i] = 1
	for i in range(100):
		if main[i] == True:
			if d.get(i + 1, False) == False:
				main[i] = False
a = []
for i in range(100):
	if main[i]:
		a.append(i + 1)
for i in a:
	print(i, end=' ')


n = int(input())
q = []
for i in range(n):
	a = list(map(int, input().split()))[1:]
	q.append(a)
r = []
for i in range(1, 101):
	if all((i in a for a in q)):
		r.append(i)
print(' '.join(map(str, r)))


def main():
	from sys import stdin, stdout
	input = stdin.readline
	print = stdout.write
	n = int(input())
	a = {}
	for i in range(n):
		for e in map(int, input().split()[1:]):
			a.setdefault(e, 0)
			a[e] += 1
	for (k, v) in a.items():
		if v == n:
			print(str(k) + ' ')
main()


n = int(input())
l = input().split()
line = list(map(int, l[1:]))
for i in range(n - 1):
	x = input().split()
	templine = []
	r = list(map(int, x[1:]))
	for i in r:
		if i in line:
			templine.append(i)
	line = list(templine)
print(*line)


n = int(input())
s = set(input().split()[1:])
for _ in range(n - 1):
	s = s.intersection(set(input().split()[1:]))
print(*s)


def main():
	from sys import stdin, stdout
	input = stdin.readline
	print = stdout.write
	n = int(input())
	a = [0 for i in range(100)]
	for i in range(n):
		for e in map(int, input().split()[1:]):
			a[e - 1] += 1
	for (i, e) in enumerate(a):
		if e == n:
			print(str(i + 1) + ' ')
main()


stops = int(input())
hash = dict(((e, 1) for e in input().split(' ')[1:]))
for i in range(stops - 1):
	list = input().split(' ')[1:]
	hash2 = {}
	for l in list:
		if l in hash:
			hash2[l] = 1
	hash = hash2
for i in hash.keys():
	print(i, end=' ')


n = int(input())
k = []
for i in range(n):
	a = tuple(map(int, input().split()))
	k.append(a[1:])
k = tuple(sorted(k, key=lambda x: len(x)))
for i in k[0]:
	ans = 0
	for j in k:
		if i in j:
			ans += 1
	if ans % n == 0:
		print(i, end=' ')


n = int(input())
a = [j for j in input().split()]
a = set(a[1:])
for i in range(n - 1):
	b = [j for j in input().split()]
	b = set(b[1:])
	a = a & b
for i in a:
	print(i, end=' ')


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
ans = set(li()[1:])
for i in range(n - 1):
	a = set(li()[1:])
	ans = ans & a
print(wr(list(ans)))


n = int(input())
result_list = list(map(int, input().split()))[1:]
for _ in range(1, n):
	l = list(map(int, input().split()))[1:]
	temp = []
	for i in result_list:
		if i in l:
			temp.append(i)
	result_list = temp[:]
print(*set(temp))


def input_list():
	return map(int, input().split())

def main():
	n = int(input())
	stops = []
	for i in range(n):
		new_stops = list(input_list())[1:]
		stops = new_stops if i == 0 else [stop for stop in stops if stop in new_stops]
	print(' '.join([str(stop) for stop in stops]))
main()


n = int(input())
s = set()
for i in range(n):
	x = list(map(int, input().split()))
	tmp = set()
	for r in x[1:]:
		tmp.add(r)
	if len(s) == 0:
		s = tmp
	else:
		s = s.intersection(tmp)
		if len(s) == 0:
			exit()
print(*s)


n = int(input())
a = [0] * 101
for i in range(n):
	x = list(map(int, input().split(' ')))
	for j in range(1, len(x)):
		a[x[j] - 1] += 1
for i in range(len(a)):
	if a[i] == n:
		print(i + 1, end=' ')


l = []
n = int(input())
for _ in range(n):
	(r, *s) = map(int, input().split())
	l.append(s)
final = []
for j in l[0]:
	if j in l[1]:
		final.append(j)
for i in range(2, n):
	for j in final:
		if j not in l[i]:
			final.remove(j)
print(*final)


from collections import defaultdict, Counter, deque
read = lambda : list(map(int, input().split()))
getinfo = lambda grid: print(list(map(print, grid)))
p = lambda x: print(x, end=' ')
inf = float('inf')
mod = 10 ** 9 + 7
n = int(input())
s = set(range(101))
for _ in range(n):
	(r, *a) = read()
	s = s & set(a)
print(' '.join(map(str, list(s))))


n = int(input())
s = set([x for x in range(1, 101)])
for x in range(n):
	l = set(list(map(int, input().split()))[1:])
	s = s.intersection(l)
for x in s:
	print(x, end=' ')
print()


n = int(input())
answer = set(list(map(int, input().split()))[1:])
for i in range(n - 1):
	arr = list(map(int, input().split()))[1:]
	buff = set(arr)
	answer = answer.intersection(buff)
print(*answer)


n = int(input())
list1 = []
for i in range(n):
	(no, *l) = map(str, input().split())
	if i == 0:
		list1 = list(l)
	elif i > 0:
		for j in range(len(list1)):
			if list1[j] not in l:
				list1[j] = 0
for i in list1:
	if i != 0:
		print(i, end=' ')


from collections import Counter
n = int(input())
s = []
p = 1000
for i in range(0, n):
	f = list(map(int, input().split()))
	p = min(f[0], p)
	del f[0]
	s += f
v = Counter(s)
for i in v:
	if v[i] == n:
		print(i, end=' ')


def prog():
	from sys import stdin
	n = int(stdin.readline())
	s = set(map(int, stdin.readline().split()[1:]))
	for i in range(n - 1):
		d = set(map(int, stdin.readline().split()[1:]))
		s = s & d
	print(*s)
prog()


n = int(input())
dic = dict()
for i in range(n):
	numbers = input().split()
	for number in numbers[1:]:
		dic[number] = dic.get(number, 0) + 1
for (number, count) in list(dic.items()):
	if count is n:
		print(number, end=' ')


def program():
	global l
	(length, *stops) = list(map(int, input().strip().split()))
	stops = set(stops)
	if l == set():
		l = stops
	else:
		l.intersection_update(stops)
case = int(input())
l = set()
for i in range(case):
	program()
print(' '.join(map(str, l)))


from sys import stdin
n = int(stdin.readline().strip())
s = set(list(map(int, stdin.readline().strip().split()))[1:])
for i in range(n - 1):
	s1 = set(list(map(int, stdin.readline().strip().split()))[1:])
	s2 = set()
	for i in s1:
		if i in s:
			s2.add(i)
	s = s2.copy()
print(*list(s))


n = int(input())
res = None
for i in range(n):
	its = [int(k) for k in input().split()]
	s = set(its[1:])
	if res is None:
		res = s
	else:
		res &= s
print(*res)


n = int(input())
m = n
l = []
osl = 0
legn = 0
while m > 0:
	a = input()
	b = a.split()
	k = 1
	e = b[0]
	e = int(e)
	while k <= e:
		s = b[k]
		s = int(s)
		l.append(s)
		if s > legn:
			legn = s
		osl = osl + 1
		k = k + 1
	m = m - 1
szam = 0
vegl = []
vegsz = -1
while szam <= legn:
	counter = 0
	ae = 0
	while ae < osl:
		if l[ae] == szam:
			counter = counter + 1
		ae = ae + 1
	if counter == n:
		vegl.append(szam)
		vegsz = vegsz + 1
	szam = szam + 1
for i in vegl:
	print(i, end=' ')


n = int(input())
r = set(list(map(int, input().split(' ')))[1:])
for _ in range(1, n):
	arr = set(list(map(int, input().split(' ')))[1:])
	r = r & arr
print(*r)


import sys
input = sys.stdin.readline
n = int(input())
count = {}
for i in range(n):
	a = set(list(map(int, input().split()))[1:])
	for j in a:
		if j not in count.keys():
			count[j] = 0
		count[j] += 1
ans = []
for key in count.keys():
	if count[key] == n:
		ans.append(key)
print(' '.join([str(x) for x in ans]))


n = int(input())
A = {}
B = {}
for i in range(n):
	if A:
		B = set(list(map(int, input().split()))[1:])
		A &= B
	else:
		A = set(list(map(int, input().split()))[1:])
print(' '.join(map(str, A)))


def main_function():
	collector = []
	n = int(input())
	for i in range(n):
		collector += [int(i) for i in input().split(' ')][1:]
	hash_table = [0 for i in range(102)]
	for i in collector:
		hash_table[i] += 1
	output_list = []
	for j in range(len(hash_table)):
		if hash_table[j] == n:
			output_list.append(str(j))
	return ' '.join(output_list)
print(main_function())


s = set(list(range(1, 101)))
for i in range(int(input())):
	l = set(list(map(int, input().split()))[1:])
	s = s & l
s = list(s)
print(*s)


n = int(input())
a = [i for i in range(1, 101)]
for i in range(n):
	b = [int(i) for i in input().split()][1:]
	c = []
	for el in a:
		if el in b:
			c.append(el)
	a = c[:]
print(*a)


n = int(input())
ans = set()
l = list(map(int, input().split()))
for i in range(1, len(l)):
	ans.add(l[i])
for t in range(1, n):
	l = list(map(int, input().split()))
	k = set()
	for i in range(1, len(l)):
		k.add(l[i])
	ans = ans.intersection(ans, k)
for i in ans:
	print(i, end=' ')


def intersect(a1, a2):
	t1 = a1.copy()
	t2 = a2.copy()
	t1.sort()
	t2.sort()
	result = []
	while t1 and t2:
		if t1[-1] == t2[-1]:
			result.append(t1.pop())
			t2.pop()
		elif t1[-1] > t2[-1]:
			t1.pop()
		else:
			t2.pop()
	return result

class CodeforcesTask1056ASolution:

	def __init__(self):
		self.result = ''
		self.stop_count = 0
		self.stops = []

	def read_input(self):
		self.stop_count = int(input())
		for x in range(self.stop_count):
			self.stops.append([int(y) for y in input().split(' ')])

	def process_task(self):
		stops = [x[1:] for x in self.stops]
		lines = stops[0]
		for x in range(1, len(stops)):
			lines = intersect(lines, stops[x])
		self.result = ' '.join([str(x) for x in lines])

	def get_result(self):
		return self.result
Solution = CodeforcesTask1056ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
R = [list(map(int, input().split())) for i in range(n)]
SET = set(R[0][1:])
for i in range(1, n):
	SET = SET & set(R[i][1:])
for s in SET:
	print(s, end=' ')


n = int(input())
l = []
for i in range(n):
	k = list(map(int, input().split()))
	l.append(k[1:])
s = set(l[0])
for i in range(1, n):
	s = s.intersection(l[i])
ll = list(s)
ll.sort()
print(*ll)


n = int(input())
ans = set()
for i in range(n):
	A = list(map(int, input().split()))
	S = set(A[1:])
	if i == 0:
		ans = S
	else:
		ans &= S
print(*ans)


n = int(input())
stops = (set((int(c) for c in input().split()[1:])) for _ in range(n))
print(*set.intersection(*stops))


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	del a[i][0]
	a[i] = set(a[i])
res = set.intersection(*a)
for i in res:
	print(i, end=' ')


import sys

def mp():
	return list(map(int, input().split()))

def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(set(mp()[1:]))
	for i in range(1, n):
		a[0] = a[0] & a[i]
	print(*a[0])
koala = 0
if koala:
	file = open('input.txt', 'r')
	input = file.readline
else:
	input = sys.stdin.readline
main()
if koala:
	file.close()


n = int(input())
fin = set()
for i in range(n):
	u = list(map(int, input().split()))
	u.pop(0)
	j = set(u)
	if i == 0:
		fin = j
	else:
		fin.intersection_update(j)
print(*fin)


n = int(input())
arr = input().split()[1:]
ans = set(arr)
for i in range(n - 1):
	arr = input().split()[1:]
	ans &= set(arr)
print(' '.join(ans))


def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3
n = int(input())
lst = [int(x) for x in input().split()]
lst.remove(lst[0])
n -= 1
while n > 0:
	lst1 = [int(x) for x in input().split()]
	lst1.remove(lst1[0])
	lst = intersection(lst, lst1)
	n -= 1
for i in lst:
	print(i, end=' ')


n = int(input())
m = set()
l = [int(i) for i in input().split()]
for j in range(1, l[0] + 1):
	m.add(l[j])
res = m
m = set()
for i in range(n - 1):
	l = [int(i) for i in input().split()]
	for j in range(1, l[0] + 1):
		m.add(l[j])
	res = res & m
	m = set()
for i in res:
	print(i, end=' ')


query = int(input())
a = []
s = ''
for _ in range(query):
	(n, *l) = map(int, input().split())
	if not a:
		a += l
		k = len(a)
	else:
		for i in range(k):
			p = False
			for j in range(n):
				if a[i] == l[j]:
					p = True
					break
			if not p:
				a[i] = 0
for i in a:
	if i > 0:
		s += str(i) + ' '
print(s)


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
ar = []
n = get_single_int()
for i in range(n):
	ar.append(get_list())
ans = []
for i in ar[0][1:]:
	for j in range(1, n):
		if i in ar[j][1:]:
			if j == n - 1:
				ans.append(i)
		else:
			break
print(*ans)


import math, itertools
MOD = 1000000007
first_line = input().split(' ')
num_of_stops = int(first_line[0])
all_lines = {}
stop_info = []
for n in range(num_of_stops):
	next_line = input().split(' ')[1:]
	my_lines = [arg for arg in next_line]
	stop_info.append(my_lines)
	for l in my_lines:
		all_lines[l] = True
for line in all_lines:
	for stop in stop_info:
		if line not in stop:
			all_lines[line] = False
ans = []
for (line, val) in all_lines.items():
	if val:
		ans.append(line)
ans.sort()
for a in ans:
	print(a, end=' ')
print()


s = 0
for _ in [0] * int(input()):
	a = set(map(int, input().split()[1:]))
	s = (s or a) & a
print(*s)


n = int(input())
myset = set()
for i in range(n):
	s = list(map(int, input().split()))
	(r, s) = (s[0], s[1:])
	if i == 0:
		myset = set(s)
	else:
		myset &= set(s)
print(' '.join(map(str, myset)))


ans = set(range(1, 101))
for _ in range(int(input())):
	ans &= set(list(map(int, input().split()))[1:])
print(*ans)


a = []
b = []
for i in range(int(input())):
	t = list(map(int, input().split()))
	a.append(t[0])
	b.append(t[1:])
h = a.index(min(a))
p = b[h]
g = []
o = 0
for c in p:
	l = 0
	for k in b:
		if c in k:
			pass
		else:
			l += 1
	if l == 0:
		g.append(c)
print(*g)


n = int(input())
s = [int(i) for i in input().split(' ')[1:]]
for i in range(1, n):
	l = [int(j) for j in input().split(' ')][1:]
	s = [j for j in s if j in l]
print(' '.join([str(i) for i in s]))


stops = int(input())
valid = [0] * 101
for i in range(stops):
	arr = list(map(int, input().split(' ')))
	for u in range(1, len(arr)):
		valid[arr[u]] += 1
sol = []
for i in range(101):
	if valid[i] == stops:
		sol.append(str(i))
print(' '.join(sol))


n = int(input())
res = {i for i in range(1, 101)}
for _ in range(n):
	res &= set(map(int, input().split()[1:]))
print(*res)


n = int(input())
freq = [0 for x in range(102)]
for i in range(n):
	l = list(map(int, input().split(' ')))
	for j in range(1, len(l)):
		freq[l[j]] = freq[l[j]] + 1
for x in range(0, 102):
	if freq[x] == n:
		print(x, end=' ')


n = int(input())
mas = [int(0) for i in range(102)]
maxx = 0
cnt = 0
res = []
for i in range(n):
	m = [int(j) for j in input().split()]
	for j in range(1, len(m)):
		mas[m[j]] += 1
		if mas[m[j]] > maxx:
			maxx = mas[m[j]]
for i in range(len(mas)):
	if mas[i] == maxx:
		res.append(i)
print(*res)


import sys
input = sys.stdin.buffer.readline
t = int(input())
ans = list(map(int, input().split()))
ans = set(ans[1:])
t -= 1
while t:
	t -= 1
	arr = list(map(int, input().split()))
	arr = set(arr[1:])
	ans = ans.intersection(arr)
for x in ans:
	print(x, end=' ')


n = int(input())
l = []
for i in range(n):
	m = list(map(int, input().split()))
	l.append(m)
l.sort()
min_track = l[0][0]
for i in range(1, n):
	l[i].pop(0)
small = l.pop(0)
ans = []
for i in range(min_track):
	total = 0
	for j in range(n - 1):
		if small[i + 1] in l[j]:
			total += 1
		else:
			break
		if total == n - 1:
			ans.append(str(small[i + 1]))
print(' '.join(ans))


n = int(input())
r = set()
for i in range(n):
	a = set(list(map(int, input().split()))[1:])
	if i == 0:
		r = a
	else:
		r &= a
print(' '.join(map(str, sorted(r))))


a = x = 0
for s in [*open(0)][1:]:
	b = {*s.split()[1:]}
	a = a & b if x else b
	x = 1
print(*a)


n = int(input())
v = []
for i in range(n):
	p = list(map(int, input().split()))
	m = p[0]
	if i == 0:
		v = p[1:]
	else:
		v1 = []
		for a in range(1, len(p)):
			for b in range(len(v)):
				if v[b] == p[a]:
					v1.append(v[b])
					break
		v = v1
v = sorted(v)
for i in range(len(v)):
	print(v[i], end=' ')


n = int(input())
s = set(range(1, 101))
for i in range(n):
	curr = set(list(map(int, input().split()))[1:])
	scp = s
	s = set()
	for el in scp:
		if el in curr:
			s.add(el)
for el in s:
	print(el, end=' ')
print()


n = int(input())
i = 1
l = []
while i <= n:
	l.append(set(list(map(int, input().split()))[1:]))
	for x in range(0, len(l) - 1):
		if x == 0:
			s1 = l[x]
		s1 = l[x + 1].intersection(s1)
		if len(s1) == 1:
			break
	i += 1
print(*s1)


n = int(input())
res = [0] * 101
for i in range(n):
	nums = list(map(int, input().split()))[1:]
	for num in nums:
		res[num] += 1
for (i, e) in enumerate(res):
	if e == n:
		print(i, end=' ')


n = int(input())
x = [int(x) for x in input().split()]
c = set(x[1:])
for i in range(n - 1):
	y = [int(y) for y in input().split()]
	c = c.intersection(y[1:])
print(*c)


n = int(input().strip())
ans = set(list(range(1, 101)))
for _ in range(n):
	stops = [int(x) for x in input().strip().split()]
	r = stops[0]
	ans = ans.intersection(set(stops[1:]))
for s in ans:
	print(s, end=' ')
print('')


n = int(input())
ans = list(map(int, input().split()))[1:]
for _ in range(n - 1):
	k = list(map(int, input().split()))
	em = [i for i in k[1:] if i in ans]
	ans = em
for X in ans:
	print(X, end=' ')


def main():
	from sys import stdin, stdout
	I = stdin.readline
	O = stdout.write
	n = int(I())
	a = set(range(1, 101))
	for i in range(n):
		a.intersection_update(set(map(int, I().split()[1:])))
	for e in a:
		O(str(e) + ' ')
main()


n = int(input())
l = []
m = []
for i in range(n):
	(s, *a) = list(map(int, input().split()))
	l += a
for i in set(l):
	if l.count(i) == n:
		m.append(i)
print(*m)


import sys
from collections import *

def solve(io):
	N = io.read_int()
	freq = defaultdict(lambda : 0)
	for i in range(0, N):
		R = io.read_int()
		A = io.read_int_array(R)
		for v in A:
			freq[v] += 1
	good = []
	for (line, f) in freq.items():
		if f == N:
			good.append(line)
	io.println_array(good)

class IO:
	in_stream = None
	out_stream = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, input_stream, output_stream):
		self.in_stream = input_stream
		self.out_stream = output_stream

	def read_to_buffer(self):
		self.raw = self.in_stream.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def read_string(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def read_int(self):
		return int(self.read_string())

	def read_float(self):
		return float(self.read_string())

	def read_string_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_string())
		return arr

	def read_int_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_int())
		return arr

	def read_float_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_float())
		return arr

	def read_line(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		if self.pos > 0:
			raise ValueError('Cannot call read_line in the middle of a line.')
		return self.raw

	def print(self, s):
		self.out_stream.write(str(s))

	def println(self, s):
		self.print(s)
		self.print('\n')

	def println_array(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flush_output(self):
		self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output()


n = int(input())
s = set()
for _ in range(n):
	if s:
		m = set(list(map(int, input().split()))[1:])
		s = s.intersection(m)
	else:
		s = set(list(map(int, input().split()))[1:])
print(*s)


import sys

def main():
	inp = sys.stdin.read().strip().split('\n')
	return set.intersection(*(set(i.split()[1:]) for i in inp[1:]))
print(*main())


n = int(input())
li = list(map(int, input().split()))[1:]
li = set(li)
for _ in range(1, n):
	li = li.intersection(set(list(map(int, input().split()))[1:]))
li = list(li)
for i in li:
	print(i, end=' ')
print()


n = int(input())
ans = []
for i in range(n):
	ar = tuple(map(int, input().split()))
	ans.append(set(ar[1:]))
ans = set.intersection(*ans)
print(*ans)


n = int(input())
arr = list(map(int, input().split()))
arr = set(arr[1:])
for i in range(1, n):
	tmp = list(map(int, input().split()))
	tmp = set(tmp[1:])
	if len(arr) >= 1:
		arr = arr.intersection(tmp)
print(' '.join([str(e) for e in arr]))


for i in range(int(input())):
	x = list(map(int, input().split()))
	x = x[1:]
	if i != 0:
		h = len(x)
		i = 0
		while i < h:
			if x[i] not in prev:
				x.pop(i)
				h -= 1
				i -= 1
			i += 1
		prev = x
	else:
		prev = x
print(*x)


I = lambda : map(int, input().split())
n = int(input())
(_, *A) = I()
X = set(A)
for _ in range(n - 1):
	(_, *A) = I()
	X &= set(A)
print(*X)


print(*set.intersection(*(set(map(int, input().split()[1:])) for _ in [0] * int(input()))))


amount = int(input())
first = set([int(s) for s in input().split()[1:]])
for i in range(amount - 1):
	second = set([int(s) for s in input().split()[1:]])
	first = first.intersection(second)
print(' '.join([str(s) for s in first]))


n = int(input())
ans = list()
for i in range(n):
	ans.extend(input().split()[1:])
d = list(set(ans))
for i in d:
	if ans.count(i) == n:
		print(i, end=' ')


def rd():
	temp = list(map(int, input().split()))
	temp.pop(0)
	return set(temp)
n = int(input())
r = rd()
for _ in range(n - 1):
	r = r.intersection(rd())
print(*r)


n = int(input())
s = set(list(range(1, 101)))
for i in range(n):
	a = [int(i) for i in input().split()]
	r = a.pop(0)
	cur = set(a)
	s = s.intersection(cur)
print(*s)


n = int(input())
for i in range(n):
	(k, *a) = [int(j) for j in input().split()]
	if i == 0:
		s = set(a)
	else:
		s &= set(a)
print(*s)


m = int(input())
anus = set()
for izy in range(m):
	if izy == 0:
		liza = list(map(int, input().split()))
		liza.pop(0)
		anus.update(liza)
	else:
		liza = list(map(int, input().split()))
		liza.pop(0)
		anus.intersection_update(liza)
print(*anus)


n = int(input())
stops = None
for i in range(n):
	temp = [k for k in input().split()]
	if not stops:
		stops = set(temp[1:])
	else:
		stops = stops & set(temp[1:])
result = ' '.join(stops)
print(result)


print(*set.intersection(*[set(list(map(int, input().split()))[1:]) for _ in range(int(input()))]))


n = int(input())
cnt = [0] * 101
for x in range(n):
	lst = [int(y) for y in input().split()]
	for i in range(1, len(lst)):
		cnt[lst[i]] += 1
for x in range(1, 101):
	if cnt[x] == n:
		print(x, end=' ')


def check(line):
	for s in stop[1:]:
		if line not in s:
			return False
	return True
n = int(input())
stop = []
ans = []
for i in range(n):
	s = list(map(int, input().split()))
	s = s[1:]
	stop.append(s)
stop.sort(key=len)
for line in stop[0]:
	if check(line):
		ans.append(line)
print(*ans)


a = int(input())
l = [int(x) for x in input().split()]
del l[0]
p = l
for i in range(a - 1):
	b = [int(x) for x in input().split()]
	del b[0]
	l = list(set(l) & set(b))
for i in l:
	print(i, end=' ')


import sys
import collections
input = sys.stdin.readline

def printnl(val):
	sys.stdout.write(str(val) + '\n')
ans = collections.defaultdict(int)
t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a = a[1:]
	for i in a:
		ans[i] += 1
k = []
for v in a:
	if ans[v] == t:
		k.append(v)
print(*k)


n = int(input())
ans = set([int(x) for x in input().split()][1:])
for i in range(1, n):
	ans = ans.intersection(set([int(x) for x in input().split()][1:]))
for x in ans:
	print(f'{x}', end=' ')
print()


n = int(input())
l = list(map(int, input().split()))
s = set(l[1:])
for i in range(n - 1):
	l1 = list(map(int, input().split()))
	s1 = set(l1[1:])
	s = s.intersection(s1)
for i in s:
	print(i, end=' ')


n = int(input())
a = []
maxlen = 0
for i in range(0, n):
	a.append(list(map(int, input().split())))
	if len(a[i]) - 1 > maxlen:
		maxlen = len(a[i]) - 1
	del a[i][0]
for i in range(0, n - 1):
	if i == 0:
		c = list(set(a[i]) & set(a[i + 1]))
	else:
		c = list(set(c) & set(a[i + 1]))
for i in c:
	print(i, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
a = set(a[1:])
for i in range(n - 1):
	x = [int(i) for i in input().split()]
	x = set(x[1:])
	a = a & x
for i in a:
	print(i, end=' ')


n = int(input())
lines = [0 for _ in range(101)]
for _ in range(n):
	veci = list(map(int, input().split()))
	for i in range(1, len(veci)):
		lines[veci[i]] += 1
for i in range(len(lines)):
	if lines[i] == n:
		print(i, end=' ')
print()


n = int(input())
ans = [0] * 110
for i in range(n):
	r = list(map(int, input().split()))
	r[0] = 0
	for j in r:
		ans[j] += 1
for i in range(1, 110):
	if ans[i] == n:
		print(i, end=' ')


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
s0 = set()
for i in range(N):
	za = getIntList()
	ss = set(za[1:])
	if len(s0) == 0:
		s0 = ss
	else:
		s0 &= ss
for x in s0:
	print(x, end=' ')


n = int(input())
ls = []
for i in range(n):
	inp = list(map(int, input().split()))
	s = set(inp[1:])
	ls.append(s)
while len(ls) > 1:
	ls[0] = ls[0].intersection(ls[1])
	ls.pop(1)
for i in ls[0]:
	print(f'{i} ', end='')


num = int(input())
a = []
for _ in range(num):
	a.append([int(x) for x in input().split()][1:])
b = [set(x) for x in a]
n = b[0]
for i in b:
	n = i.intersection(n)
for i in n:
	print(i)


n = int(input())
S = set(list(map(int, input().split()))[1:])
for i in range(n - 1):
	A = set(list(map(int, input().split()))[1:])
	S = S.intersection(A)
print(*S)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
n = get_int()
s = set(get_int_list()[1:])
for i in range(n - 1):
	s = s.intersection(set(get_int_list()[1:]))
lst = list(s)
print(*lst)


n = int(input())
c = []
for i in range(0, n):
	m = list(map(int, input().split()))
	c.append(m[1:])
k = set(c[0])
for j in range(1, len(c)):
	k = k.intersection(set(c[j]))
k = list(k)
for t in range(0, len(k)):
	print(k[t], end=' ')


from collections import Counter

def solve():
	lines = []
	nr = int(input())
	for i in range(nr):
		(n, *r) = [int(x) for x in input().split(' ')]
		lines += r
	c = Counter(lines)
	ans = [x for x in c if c[x] == nr]
	print(' '.join([str(x) for x in ans]))
solve()


n = int(input())
res = set([*map(int, input().split())][1:])
for _ in range(n - 1):
	s = set([*map(int, input().split())][1:])
	res = res.intersection(s)
print(' '.join(map(str, res)))


s = input().split()
n = int(s[0])
for i in range(n):
	if not i:
		ans = set(list(map(int, input().split()))[1:])
	else:
		ans &= set(list(map(int, input().split()))[1:])
print(' '.join(map(str, ans)))


n = int(input())
a = list(map(int, input().split()))
a.remove(a[0])
a = set(a)
for i in range(n - 1):
	b = list(map(int, input().split()))
	b.remove(b[0])
	b = set(b)
	c = a.intersection(b)
	a = c
c = list(c)
print(*c)


n = int(input())
a = set(list(map(int, input().split()))[1:])
for i in range(n - 1):
	a = a & set(list(map(int, input().split()))[1:])
out = ''
for guy in a:
	out += str(guy) + ' '
print(out[:-1])


n = int(input())
a = []
k = []
for i in range(n):
	(m, *p) = list(map(int, input().split()))
	a += p
for i in set(a):
	if a.count(i) == n:
		k.append(i)
print(*k)


n = int(input())
b = list(map(int, input().split()))
c = b[1:]
c = list(set(c))
for i in range(n - 1):
	a = list(map(int, input().split()))
	a = a[1:]
	a = list(set(a))
	for i in a:
		if i in c:
			c.append(i)
l = list(set(c))
for i in l:
	if c.count(i) == n:
		print(i, end=' ')
print()


import sys
import random
import copy
from itertools import permutations, combinations
from math import sqrt, fabs, ceil
from collections import namedtuple
in_file_path = 'input.txt'
output_file_path = 'output.txt'
SUBMIT = True

def get_array(x, initial=None):
	dimension = len(x)
	if dimension == 1:
		return [copy.deepcopy(initial) for _ in range(x[0])]
	else:
		return [get_array(x[1:], initial) for _ in range(x[0])]

def read_num(fin, num_type=int):
	tmp_list = [num_type(x) for x in fin.readline().strip().split()]
	if len(tmp_list) == 1:
		return tmp_list[0]
	else:
		return tuple(tmp_list)

def read_num_list(fin, num_type=int):
	return [num_type(x) for x in fin.readline().strip().split()]

def solve(fin):
	n = read_num(fin)
	ans_set = None
	for i in range(n):
		tmp_list = read_num_list(fin)
		if ans_set == None:
			ans_set = set(tmp_list[1:])
		else:
			ans_set &= set(tmp_list[1:])
	print(' '.join([str(x) for x in ans_set]))
if SUBMIT:
	solve(sys.stdin)
else:
	solve(open(in_file_path, 'r'))


n = int(input())
k = []
for i in range(n):
	a = tuple(map(int, input().split()))
	k.append(set(a[1:]))
k = set.intersection(*k)
print(*k)


n = int(input())
for x in range(n):
	(r, *l) = map(int, input().strip().split())
	if x == 0:
		k = set(l)
	else:
		k = k.intersection(set(l))
print(*k)


n = int(input())
s = {}
for i in range(n):
	ln = input().split()
	for i in range(len(ln)):
		ln[i] = int(ln[i])
	for i in range(1, len(ln)):
		if ln[i] not in s:
			s[ln[i]] = 1
		else:
			s[ln[i]] += 1
j = []
for k in list(s.keys()):
	if s[k] == n:
		j.append(k)
print(' '.join((str(x) for x in j)))


n = int(input())
a = set(list(map(int, input().split()))[1:])
for _ in range(n - 1):
	a &= set(list(map(int, input().split()))[1:])
print(' '.join(map(str, a)))


n = int(input())
(k, *stations) = input().split()
stations = set(stations)
for i in range(n - 1):
	(m, *cur_s) = input().split()
	cur_s = set(cur_s)
	stations = stations & cur_s
print(*stations)


import math
n = int(input())
num = [[] for y in range(2)]
arr = []
for i in range(n):
	arr1 = list(map(int, input().split()))
	arr.append(arr1)
	num[0].append(arr1[0])
	num[1].append(i)
r = len(num[0])
for i in range(r):
	for j in range(0, r - i - 1):
		if num[0][j] > num[0][j + 1]:
			(num[0][j], num[0][j + 1]) = (num[0][j + 1], num[0][j])
			(num[1][j], num[1][j + 1]) = (num[1][j + 1], num[1][j])
have = arr[num[1][0]]
smallest = have.pop(0)
donthave = []
for i in range(1, n):
	for j in range(smallest):
		if have[j] not in arr[num[1][i]]:
			donthave.append(have[j])
res = []
[res.append(x) for x in donthave if x not in res]
for x in res:
	have.remove(x)
print(*have)


from collections import Counter
n = int(input())
last_res = []
for i in range(n):
	temp = list(map(int, input().split()))
	del temp[0]
	for j in temp:
		last_res.append(j)
last_res.sort()
res = Counter(last_res)
for i in res:
	if int(res[i]) == n:
		print(int(i), ' ', sep='', end='')


def main():
	n = int(input())
	stops = [set((int(c) for c in input().split()[1:])) for _ in range(n)]
	stop = stops[0]
	for i in range(1, n):
		stop = stop & stops[i]
	print(*stop)
main()


def read():
	return set(list(map(int, input().split()))[1:])
n = int(input())
t = read()
for _ in range(n - 1):
	t = t & read()
for x in t:
	print(x, end=' ')
print()


n = int(input())
a = []
c = []
d = []
for i in range(n):
	b = [int(i) for i in input().split()]
	b = b[1:len(b)]
	if i == 0:
		c = b
	elif i == 1:
		for j in b:
			if j in c:
				a += [j]
	elif i % 2 == 0:
		for j in b:
			if j in a:
				d += [j]
		a = []
	else:
		for j in b:
			if j in d:
				a += [j]
		d = []
if a == []:
	a = d
for i in a:
	print(i, ' ', end='')


(n, d) = (int(input()), dict())
for i in range(n):
	(n1, *l) = input().split()
	for i in range(int(n1)):
		if l[i] not in d:
			d[l[i]] = 1
		else:
			d[l[i]] += 1
print(*[i for i in d if d[i] == n])


n = int(input())
a = []
ans = []
for i in range(n):
	b = list(map(int, input().split()))
	k = len(b)
	for j in range(1, k):
		a.append(b[j])
b = a[:]
b = list(set(b))
for i in range(len(b)):
	if a.count(b[i]) == n:
		ans.append(b[i])
print(*ans)


n = int(input())
k = dict()
for i in range(n):
	(r, *a) = [int(s) for s in input().split()]
	for elem in a:
		k[elem] = k.get(elem, 0) + 1
for key in k:
	if k[key] == n:
		print(key, end=' ')


n = int(input())
a = []
ans = []
for i in range(n):
	s = input().split()
	r = int(s[0])
	a.append([])
	for j in range(r):
		a[i].append(int(s[j + 1]))
for i in range(len(a[0])):
	flag = True
	for j in range(n):
		if a[0][i] not in a[j]:
			flag = False
	if flag:
		ans.append(a[0][i])
for i in range(len(ans)):
	print(ans[i], end=' ')


n = int(input())
d = {}
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(1, l[i][0] + 1):
		if l[i][j] in d:
			d[l[i][j]] += 1
		else:
			d[l[i][j]] = 1
for i in d:
	if d[i] == n:
		print(i, end=' ')


n = int(input())
a = set(range(1, 101))
for i in range(n):
	a.intersection_update(set(map(int, input().split()[1:])))
for e in a:
	print(e, end=' ')


def sr(el):
	return el[1]
n = int(input())
sl = {}
for _ in ' ' * n:
	sp = list(map(int, input().split()))[1:]
	for el in sp:
		sl[el] = sl.get(el, 0) + 1
t = list(sl.items())
mx = max(t, key=sr)
for el in t:
	if el[1] == mx[1]:
		print(el[0], end=' ')


n = int(input())
r = list(map(int, input().split()))
s = r[1:]
for i in range(n - 1):
	r = list(map(int, input().split()))
	r = r[1:]
	q = len(s)
	t = []
	for j in r:
		if j in s:
			t.append(j)
	s = t
s = sorted(s)
print(' '.join(map(str, s)))


n = int(input())
S = set(range(0, 101))
for i in range(n):
	s = input().split()
	m = int(s[0])
	S1 = set()
	for i in range(1, m + 1):
		S1.add(int(s[i]))
	S &= S1
print(*S)


q = int(input())
ch = []
for i in range(q):
	ch.append(list(map(int, input().split())))
	ch[i].pop(0)
for i in range(1, q):
	curr = []
	for y in range(len(ch[i])):
		if ch[i][y] in ch[0]:
			curr.append(ch[i][y])
	ch[0] = curr
print(*ch[0])


n = int(input())
s = []
for i in range(n):
	k = list(map(int, input().split()))
	s.append(set(k[1:]))
j = s[0]
for i in range(1, n):
	j = j & s[i]
print(*j)


n = int(input())
nn = n
li = dict()
while nn > 0:
	li1 = input().split()
	for i in range(len(li1)):
		if i == 0:
			continue
		t = int(li1[i])
		if li1[i] not in li:
			li[li1[i]] = 1
		else:
			li[li1[i]] += 1
	nn -= 1
li2 = list()
for i in li:
	if li[i] == n:
		li2.append(i)
for i in li2:
	print(i, end=' ')


t = int(input())
ans = set(list(map(int, input().split()))[1:])
for _ in range(t - 1):
	l = set(list(map(int, input().split()))[1:])
	ans = ans.intersection(l)
print(' '.join(list(map(str, ans))))


n = int(input())
d = {}
for _ in range(n):
	l = list(map(int, input().split()))[1:]
	for i in set(l):
		d.setdefault(i, 0)
		d[i] += 1
result = []
for (key, item) in d.items():
	if item == n:
		result.append(key)
print(*result)


n = int(input())
stops = []
res = [0] * 100
sRes = ''
for i in range(n):
	line = input()
	stops.append(line.split(' '))
for i in stops:
	for j in i[1:]:
		res[int(j) - 1] = res[int(j) - 1] + 1
for i in range(len(res)):
	if res[i] == n:
		sRes = sRes + str(i + 1) + ' '
print(sRes)


n = int(input())
freq = [0] * 101
for i in range(n):
	m = [int(i) for i in input().split()][1:]
	for el in m:
		freq[el] += 1
for i in range(101):
	if freq[i] == n:
		print(i, end=' ')


n = int(input())
b = [0] * 101
for i in range(n):
	x = list(map(int, input().split()))
	for i in range(1, len(x)):
		b[x[i]] += 1
c = []
for i in range(len(b)):
	if b[i] == n:
		c.append(i)
print(*c)


n = int(input())
l = [0 for i in range(100)]
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(a[0]):
		l[a[1 + i] - 1] += 1
for i in range(len(l)):
	if l[i] == n:
		print(i + 1, end=' ')


x = []
for _ in range(int(input())):
	a = list(map(int, input().split()))
	x.append(a[1:])
ans = set.intersection(*map(set, x))
print(*ans)


n = int(input())
nn = []
while n > 0:
	(a, *b) = [int(i) for i in input().split()]
	nn.append(b)
	n -= 1
inter = lambda a, b: [i for i in a if i in b]
j = 2
r = inter(nn[0], nn[1])
while j < len(nn):
	r = inter(r, nn[j])
	j += 1
print(' '.join([str(j) for j in r]))


t = int(input())
B = []
n = 0
for i in range(0, t):
	A = list(map(int, input().split()))
	if i == 0:
		n = A[0]
	A = A[1:]
	B.append(A)
list1 = []
for i in range(n):
	for j in range(1, t):
		if B[0][i] in B[j]:
			f = 1
		else:
			f = 0
			break
	if f == 1:
		list1.append(B[0][i])
for i in range(len(list1)):
	print(list1[i], end=' ')


n = int(input())

def intersect(a, b):
	x = []
	for i in a:
		if i in b:
			x.append(i)
	return x
things = [input().split()[1:] for i in range(n)]
ans = things[0]
for i in range(1, n):
	ans = intersect(ans, things[i])
print(' '.join(ans))


t = int(input())
k = list(map(int, input().split()))
del k[0]
for i in range(t - 1):
	a = list(map(int, input().split()))
	del a[0]
	k = list(set(k) & set(a))
k = ' '.join(map(str, k))
print(k)


n = int(input())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	del b[0]
	a.append(b)
b = a[0]
for i in range(1, len(a)):
	b = list(set(b) & set(a[i]))
for i in range(len(b)):
	print(b[i], end=' ')


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	n = int(input())
	current = set()
	for i in range(n):
		(r, *a) = map(int, input().split())
		if i == 0:
			for j in range(len(a)):
				current.add(a[j])
		else:
			cur = set()
			for j in range(len(a)):
				if a[j] not in current:
					continue
				else:
					cur.add(a[j])
			current &= cur
	for k in current:
		print(k, end=' ')
	return
main()


n = int(input())
a = set()
for i in range(n):
	t = list(map(int, input().split()))
	b = set(t[1:])
	if i == 0:
		a = b
	else:
		temp_set = a & b
		a = temp_set
print(*a)


n = int(input())
d = {}
for i in range(n):
	s = input().split()
	for j in range(1, len(s)):
		if s[j] in d:
			d[s[j]] += 1
		else:
			d[s[j]] = 1
for i in d.keys():
	if d[i] == n:
		print(i, end=' ')


n = int(input())
(a, *l) = list(map(int, input().split()))
l = set(l)
for x in range(n - 1):
	(c, *d) = list(map(int, input().split()))
	d = set(d)
	l = l.intersection(d)
print(*l)


n = int(input())
x = []
m = []
mi = float('inf')
for i in range(n):
	a = list(map(int, input().split()))
	x.append(sorted(a[1:]))
	m.append(len(a[1:]))
mi = m.index(min(m))
y = x.index(x[mi])
s = []
for j in range(len(x[y])):
	flag = 0
	for i in range(n):
		if x[y][j] not in x[i]:
			flag = 1
	if flag == 0:
		s.append(x[y][j])
print(*s)


n = int(input())
arr = []
for i in range(n):
	arr.append(set([int(i) for i in input().split()][1:]))
x = arr[0] & arr[1]
for i in range(2, len(arr)):
	x &= arr[i]
print(*x)


n = int(input())
l1 = list(map(int, input().split()))[1:]
s = set(l1)
for i in range(n - 1):
	l1 = list(map(int, input().split()))[1:]
	s &= set(l1)
print(' '.join(map(str, list(s))))


n = int(input())
a = []
ans = []
for i in range(101):
	a.append(0)
for i in range(n):
	s1 = input().split()
	for i in range(1, len(s1), +1):
		a[int(s1[i])] += 1
for i in range(101):
	if a[i] == n:
		ans.append(i)
for i in range(len(ans)):
	print(ans[i])


n = int(input())
x = list(map(int, input().split()))
x = x[1:x[0] + 1]
lenx = len(x)
for i in range(1, n):
	r = list(map(int, input().split()))
	for j in range(0, lenx):
		if not x[j] in r[1:r[0] + 1]:
			x[j] = -1
x = sorted(x)
for i in range(0, len(x)):
	if x[i] > 0:
		print(x[i], end=' ')


n = int(input())
x = list(input().split()[1:])
x = set(x)
for i in range(n - 1):
	y = list(input().split()[1:])
	y = set(y)
	x = x & y
for j in x:
	print(j, end=' ')


import sys
import math
from collections import Counter
n = int(input())
res = set()
for i in range(n):
	(_, *trams) = [int(i) for i in input().split()]
	trams = set(trams)
	if i == 0:
		res = trams
	else:
		res = res.intersection(trams)
print(*res)


a = int(input())
c = []
b = []
for i in range(a):
	c.append(list(map(int, input().split())))
for i in range(a):
	b.append(set(c[i][1:]))
g = b[0]
for i in b[1:]:
	g.intersection_update(i)
print(*g)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	M = []
	for i in range(n):
		A = read_ints()
		M.append(set(A[1:]))
	x = M[0]
	for a in M:
		x &= a
	print_nums(list(x))

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
fir = set(list(map(int, input().split()))[1:])
for i in range(1, n):
	fir = fir.intersection(set(list(map(int, input().split()))[1:]))
print(*fir)


n = int(input())
bzz = {}
u = []
for i in range(n):
	m = input().split()
	m = m[1:]
	for elem in m:
		if elem in bzz:
			bzz[elem] += 1
		else:
			bzz[elem] = 1
for k in bzz:
	if bzz[k] == n:
		u.append(k)
print(' '.join(u))


t = int(input())
k = 0
l = []
c = []
m = []
a = list(map(int, input().split()))
a.remove(a[0])
t = t - 1
while t:
	t = t - 1
	b = list(map(int, input().split()))
	b.remove(b[0])
	z = set(a).intersection(set(b))
	if len(m) == 0:
		m.extend(z)
	else:
		z = z.intersection(set(m))
		m = []
		m.extend(z)
	a = b.copy()
if t == 1:
	print(*a)
else:
	print(*m)


d = dict()
for i in range(1, 101):
	d[i] = 0
n = int(input())
for _ in range(n):
	a = list(map(int, input().split()))
	for i in range(1, len(a)):
		d[a[i]] += 1
for i in range(1, 101):
	if d[i] == n:
		print(i, end=' ')


n = int(input())
g = []
for _ in range(n):
	a = [int(x) for x in input().split()]
	a = a[1:]
	if _ == 0:
		l = a
	else:
		l = set(l)
		l = l.intersection(a)
print(*l)


n = int(input())
l = [int(i) for i in input().split()]
s = set(l[1:])
for i in range(n - 1):
	l1 = [int(i) for i in input().split()]
	s = s.intersection(set(l1[1:]))
print(*list(s))


n = int(input())
sets = []
for i in range(n):
	b = [x for x in input().split()]
	sets.append(set(b[1:]))
ans = sets[0]
for i in range(1, n):
	ans = ans & sets[i]
print(' '.join(list(ans)))


import math
n = int(input())
count = [0 for x in range(101)]
for i in range(n):
	numbers = [*map(int, input().split())]
	first = False
	for val in numbers:
		if first == False:
			first = True
			continue
		count[val] += 1
for index in range(101):
	if count[index] == n:
		print(index)


from collections import Counter
n = int(input())
stops = list()
mar = list()
cnt = Counter()
for x in range(n):
	stops.append(tuple(map(int, input().split(' ')[1:])))
	for y in stops[-1]:
		cnt[y] += 1
for x in cnt.keys():
	if cnt[x] == n:
		mar.append(x)
for x in mar:
	print(x, end=' ')


n = int(input())
a = set(range(101))
for _ in range(n):
	x = [int(w) for w in input().split()]
	a = a.intersection(x[1:])
print(*a)


R = lambda : set([*map(int, input().split())][1:])
n = int(input()) - 1
s = R()
for _ in [0] * n:
	s &= R()
print(*s)


m = [0 for _ in range(101)]
n = int(input())
for i in range(n):
	x = tuple(map(int, input().split()))
	for j in x[1:]:
		m[j] += 1
for i in range(1, 101):
	if m[i] == n:
		print(i, end=' ')


n = int(input())
b = [0] * 101
for _ in range(n):
	a = list(map(int, input().split()))
	for x in a[1:]:
		b[x] += 1
for (i, x) in enumerate(b):
	if x == n:
		print(i, end=' ')
print()


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def summarizeList(l):
	sl = sorted(l)
	a = sl[0]
	c = 1
	res = []
	for x in sl[1:]:
		if x == a:
			c += 1
		else:
			res.append([a, c])
			a = x
			c = 1
	res.append([a, c])
	return res

def main():
	n = I()
	l = []
	for _ in range(n):
		_l = LI()
		l += _l[1:]
	sl = summarizeList(l)
	ans = []
	for (x, c) in sl:
		if c == n:
			ans.append(x)
	return ' '.join((str(x) for x in ans))
print(main())


n = int(input())
for i in range(n):
	b = []
	if i == 0:
		a = list(map(int, input().split()))
		temp = a[1:]
	else:
		a = list(map(int, input().split()))
		a = a[1:]
		for i in range(len(a)):
			if a[i] in temp:
				b.append(a[i])
		temp = b
print(*temp)


n = int(input())
import collections
dat = []
for i in range(n):
	dat.append(dict())
for i in range(n):
	buf = list(map(int, input().split()))
	for x in buf[1:]:
		dat[i][x] = True
res = 0
final = []
for k in dat[i].keys():
	can = True
	for i in range(n):
		if k not in dat[i]:
			can = False
	if can:
		final.append(str(k))
print(' '.join(final))


n = int(input())
a = []
min_r = 100
min_i = 0
for i in range(n):
	ta = list(map(int, input().split()))
	r = ta[0]
	a.append(ta[1:])
	if r < min_r:
		min_r = r
		min_i = i
for i in a[min_i]:
	f = 1
	for j in range(n):
		s = i in set(a[j])
		if s == False:
			f = 0
			break
	if f:
		print(i, end=' ')


n = int(input())
xs = list(map(int, input().split()))[1:]
n -= 1
for _ in range(n):
	ys = list()
	for z in list(map(int, input().split()))[1:]:
		if z in xs:
			ys.append(z)
	xs = ys
xs.sort()
print(' '.join([str(x) for x in xs]))


n = int(input())
for t in range(n):
	a = list(map(int, input().split()))
	if t == 0:
		x = set(a[1:])
	x = x & set(a[1:])
print(' '.join(map(str, list(x))))


n = int(input())
lists = []
elems = set()
for _ in range(n):
	a = list(map(int, input().split(' ')))
	a = a[1:]
	lists.append(a)
	for x in a:
		elems.add(x)
ans = []
for x in elems:
	common = 0
	for i in range(n):
		if x in lists[i]:
			common += 1
	if common == n:
		ans.append(x)
print(*ans)


n = int(input())
hs = {i for i in range(1000)}
for _ in range(n):
	l = list(map(int, input().split()))
	s = set(l[1:])
	hs = hs.intersection(s)
print(' '.join([str(i) for i in hs]))