Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs?

If Vasya presses the button such that some bulbs connected to it are already turned on, they do not change their state, i.e. remain turned on.


-----Input-----

The first line of the input contains integers n and m (1 ≤ n, m ≤ 100) — the number of buttons and the number of bulbs respectively. 

Each of the next n lines contains x_{i} (0 ≤ x_{i} ≤ m) — the number of bulbs that are turned on by the i-th button, and then x_{i} numbers y_{ij} (1 ≤ y_{ij} ≤ m) — the numbers of these bulbs.


-----Output-----

If it's possible to turn on all m bulbs print "YES", otherwise print "NO".


-----Examples-----
Input
3 4
2 1 4
3 1 3 1
1 2

Output
YES

Input
3 3
1 1
1 2
1 1

Output
NO



-----Note-----

In the first sample you can press each button once and turn on all the bulbs. In the 2 sample it is impossible to turn on the 3-rd lamp.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
(n, m) = list(map(int, input().split()))
p = []
for i in range(n):
	l = list(map(int, input().split()))
	for k in range(1, len(l)):
		p.append(l[k])
setp = set(p)
o = []
for i in range(1, m + 1):
	o.append(i)
seto = set(o)
if len(seto) == len(setp):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
p = []
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(1, l[0] + 1):
		p.append(l[j])
if list(set(sorted(list(p)))) == list(range(1, 1 + m)):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	s.update(input().split()[1:])
if len(s) == m:
	print('YES')
else:
	print('NO')


(x, y) = map(int, input().split())
b = []
z = [i for i in range(1, y + 1)]
for i in range(x):
	a = list(map(int, input().split()))
	del a[0]
	b = list(set(b + a))
	b.sort()
if z == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = [False] * m
for i in range(n):
	g = list(map(int, input().split()))
	for i in g[1:]:
		l[i - 1] = True
if sum(l) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
s = []
for i in range(n):
	t = [int(x) for x in input().split()]
	for i in range(1, len(t)):
		s.append(t[i])
w = set(s)
if len(w) == m:
	print('YES')
else:
	print('NO')


a = [int(x) for x in input().split()]
l = []
c = 0
for i in range(a[0]):
	b = [int(y) for y in input().split()]
	del b[0]
	l = l + b
for j in range(a[1]):
	if j + 1 in l:
		c = c + 1
if c == a[1]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
isen = []
for i in range(m):
	isen.append(0)
for i in range(n):
	a = input().split()
	k = int(a[0])
	for j in range(k):
		cur = int(a[j + 1])
		isen[cur - 1] = 1
ok = True
for i in isen:
	if i == 0:
		ok = False
if ok:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for x in range(n):
	b = [int(y) for y in input().split()][1:]
	for x in b:
		s.add(x)
print(('NO', 'YES')[len(s) == m])


(n, m) = [int(x) for x in input().split()]
location = set()
for i in range(n):
	a = [int(x) for x in input().split()]
	length = len(a)
	amount = a[0]
	slocation = set(a[1:length])
	location = location.union(slocation)
u = len(location)
if u == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
b = set()
for i in range(n):
	b.update(input().split()[1:])
c = set(map(str, range(1, m + 1)))
if b == c:
	print('YES')
else:
	print('NO')


(n, m) = input().split(' ')
n = int(n)
m = int(m)
bulbs_list = []
for i in range(n):
	temp = input().split(' ')
	bulbs_list = bulbs_list + temp[1:]
bulbs_set = set(bulbs_list)
if len(bulbs_set) == m:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	s = set()
	for _ in range(n):
		l = [int(x) for x in input().split()]
		yi = l[1:]
		s = s.union(yi)
	if len(s) == m:
		print('YES')
	else:
		print('NO')
main()


(n, m) = map(int, input().split())
A = [i for i in range(1, m + 1)]
for i in range(n):
	x = list(map(int, input().split()))
	for i in x[1:]:
		if i in A:
			A.remove(i)
if len(A) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for t in range(n):
	arr = list(map(int, input().split()))
	for i in arr[1:]:
		s.add(i)
if len(s) == m:
	print('YES')
else:
	print('NO')


(buttons, bulbs) = map(int, input().split())
all_bulbs = []
for _ in range(buttons):
	array = [int(item) for item in input().split()]
	for bulb in array[1:]:
		if bulb not in all_bulbs:
			all_bulbs.append(bulb)
if len(all_bulbs) == bulbs:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
tot = set()
for _ in range(n):
	nums = list(map(int, input().split(' ')))[1:]
	tot |= set(nums)
print('YES' if len(tot) == m else 'NO')


(n, m) = [int(x) for x in input().split()]
choice = []
for i in range(n):
	choice.append([int(x) for x in input().split()[1:]])
result = []
for i in range(m):
	result.append(False)
for i in range(len(choice)):
	for j in range(len(choice[i])):
		index = choice[i][j] - 1
		result[index] = True
final_result = True
for i in result:
	if not i:
		final_result = False
if final_result:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [1] * m
for _ in range(0, n):
	b = list(map(int, input().split()))
	for i in range(1, b[0] + 1):
		if a[b[i] - 1] == 1:
			a[b[i] - 1] = 0
if not sum(a):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
on = []
for _ in range(n):
	a = list(map(int, input().split()))
	a = a[1:]
	on = on + a
x = set(on)
if len(x) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbState = [False] * m
x = []
y = []
for i in range(n):
	s = input().split()
	x = int(s[0])
	for j in range(x):
		y.append(int(s[j + 1]))
for i in y:
	bulbState[i - 1] = True
if False in bulbState:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
t = [False] * (m + 1)
for i in range(n):
	l = list(map(int, input().split()))
	for x in l[1:]:
		t[x] = True
poss = True
for x in t[1:]:
	if not x:
		poss = False
if poss:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
a = [0] * m
for i in range(n):
	b = list(map(int, input().split()))
	for j in range(1, b[0] + 1):
		a[b[j] - 1] = 1
e = 0
for i in range(m):
	if a[i] == 0:
		e = 1
		break
if e == 0:
	print('YES')
else:
	print('NO')


class CodeforcesTask615ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.b_lamps = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		for x in range(self.n_m[0]):
			self.b_lamps.append([int(x) for x in input().split(' ')])

	def process_task(self):
		on = [False for x in range(self.n_m[1])]
		for button in self.b_lamps:
			for x in range(1, len(button)):
				on[button[x] - 1] = True
		if False in on:
			self.result = 'NO'
		else:
			self.result = 'YES'

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


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	ar = list(map(int, input().split()))
	for j in ar[1:]:
		s.add(j)
if len(s) == m:
	print('YES')
else:
	print('NO')


n = list(map(int, input().split()))
arr = []
for i in range(n[0]):
	z = list(map(int, input().split()))
	for j in range(1, len(z)):
		if z[j] in arr:
			continue
		else:
			arr.append(z[j])
status = True
for i in range(1, n[1] + 1, 1):
	if i in arr:
		continue
	else:
		status = False
		break
if status:
	print('YES')
else:
	print('NO')


(switch, bulbs) = map(int, input().split())
on = []
for _ in range(switch):
	l = list(map(int, input().split()[1:]))
	on += l
on = list(set(on))
if len(on) != bulbs:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
l = [0] * (m + 1)
for _ in range(n):
	x = list(map(int, input().split()))
	for i in range(1, len(x)):
		l[x[i]] = 1
if sum(l) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = list([False for _ in range(m)])
for i in range(n):
	lamps = list(map(int, input().split(' ')))[1:]
	for lamp in lamps:
		a[lamp - 1] = True
print('YES' if a.count(True) == m else 'NO')


(n, m) = map(int, input().split())
d = {}
for i in range(n):
	s = list(map(int, input().split()))
	for i in range(1, len(s)):
		if s[i] not in d:
			d[s[i]] = 1
if len(d) == m:
	print('YES')
else:
	print('NO')


read = lambda : map(int, input().split())
(n, m) = read()
a = set()
for i in range(n):
	y = list(read())[1:]
	a |= set(y)
print('YES' if a == {i for i in range(1, m + 1)} else 'NO')


(n, m) = [int(x) for x in input().split()]
w = []
for i in range(n):
	c = [int(x) for x in input().split()]
	for x in c[1:]:
		w.append(x)
a = len(set(w))
if a == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
arr = []
for i in range(n):
	bulbs = list(map(int, input().split()))
	bulbs = bulbs[1:]
	arr.extend(bulbs)
if len(set(arr)) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	arr = input().split()
	for j in range(int(arr[0])):
		s.add(int(arr[j + 1]))
print('YES' if len(s) == m else 'NO')


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(n, m) = q()
ans = set()
for i in range(n):
	a = list(q())
	ans.update(set(a[1:]))
print('YES' if len(ans) == m else 'NO')


(n, m) = map(int, input().split())
a = [0 for i in range(m + 1)]
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(l[0]):
		a[l[j + 1]] = 1
print('YES' if a.count(0) == 1 else 'NO')


import sys
(n, m) = map(int, sys.stdin.readline().split())
ans = set()
for _ in range(n):
	alist = list(map(int, sys.stdin.readline().split()))
	for i in alist[1:]:
		ans.add(i)
if len(ans) == m:
	print('YES')
else:
	print('NO')


i = [int(x) for x in input('').split(' ')]
(n_butt, n_bulb) = (i[0], i[1])
bulbs = [0] * n_bulb
for rounds in range(n_butt):
	j = [int(x) for x in input('').split(' ')]
	total_bulbs_lit_this_round = j[0]
	position_series_of_bulb = j[1:]
	for position in position_series_of_bulb:
		bulbs[position - 1] = 1
print(['YES', 'NO'][0 in bulbs])


(a, b) = map(int, input().split())
y = []
k = 0
for i in range(0, a):
	x = list(map(int, input().split()))
	y.extend(x[1:])
for i in range(1, b + 1):
	if y.count(i) < 1:
		k = -1
		print('NO')
		break
if k == 0:
	print('YES')


(n, m) = map(int, input().split())
a = []
s = set()
for i in range(n):
	a.append([x for x in input().split()])
	del a[i][0]
	s = s | set(a[i])
print('YES' if len(s) == m else 'NO')


R = lambda : map(int, input().split())
(n, m) = R()
s = set()
for _ in range(n):
	x = [_ for _ in R()]
	for i in range(1, len(x)):
		s.add(x[i])
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
s = set()
for i in range(n):
	a = map(int, input().split())
	t = 0
	for num in a:
		if t == 0:
			t += 1
		else:
			s.add(num)
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
b = []
for i in range(n):
	l = list(map(int, input().split()))
	for j in l[1:]:
		b.append(j)
if len(set(b)) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbs = []
for i in range(n):
	bulb = [int(x) for x in input().split()]
	for k in range(0, bulb[0]):
		bulbs.append(bulb[k + 1])
for j in range(0, m):
	if j + 1 not in bulbs:
		print('NO')
		break
else:
	print('YES')


(n, m) = input('').split(' ')
(n, m) = (int(n), int(m))
t = []
for i in range(n):
	t.append(list(map(int, input('').split(' '))))
h = []
for j in t:
	for k in range(1, j[0] + 1):
		h.append(j[k])
count = 0
for p in range(1, m + 1):
	for o in h:
		if p == o:
			count += 1
			break
if count == m:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
s = [0] * (k + 1)
for i in range(n):
	a = list(map(int, input().split()))
	for j in a[1:]:
		s[j] = 1
print('YES' if sum(s) == k else 'NO')


(n, m) = map(int, input().split())
a = set()
bulbx = []
b = 0
for i in range(n):
	bulb = [int(x) for x in input().split()]
	bulbx = bulbx + bulb[1:]
for i in range(1, m + 1):
	if i in bulbx:
		b = b + i
if b == m * (m + 1) / 2:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
d = [False] * n
for i in range(m):
	for j in map(int, input().split()[1:]):
		d[j - 1] = True
print('YES' if all(d) else 'NO')


flag = True
line = input().split()
buttons = int(line[0])
bulps = int(line[1])
array_of_bulbs = []
for i in range(buttons):
	line_input = input().split()
	for i in range(1, len(line_input)):
		array_of_bulbs.append(int(line_input[i]))
for i in range(1, bulps + 1):
	if i not in array_of_bulbs:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
L = []
for _ in range(n):
	s = list(map(int, input().split()))
	s.remove(s[0])
	s1 = set(s)
	for i in s1:
		L.append(i)
for i in range(1, m + 1):
	if i not in L:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
a = []
b = []
fl = 1
for i in range(m + 1):
	a.append(0)
for i in range(n):
	b = list(map(int, input().split()))
	for i in range(1, len(b)):
		a[b[i]] = 1
for i in range(1, m + 1):
	if a[i] == 0:
		fl = 0
if fl == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = set()
for i in range(1, m + 1):
	l.add(i)
d = set()
for i in range(n):
	s = list(map(int, input().split()))
	del s[0]
	d.update(s)
if d == l:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
arr = [0 for i in range(m)]
for i in range(n):
	brr = list(map(int, input().split()))
	for j in brr[1:]:
		arr[j - 1] += 1
if 0 in arr:
	print('NO')
else:
	print('YES')


(button, bulb) = [int(x) for x in input().split()]
light = []
light = set(light)
for i in range(button):
	on = [int(x) for x in input().split()]
	on.pop(0)
	light = light | set(on)
num = len(light)
if num < bulb:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split(' '))
all_working_bulbs = []
for swtch in range(n):
	inst = list(map(int, input().split(' ')))
	for i in range(1, inst[0] + 1):
		all_working_bulbs.append(inst[i])
all_bulbs = list(set(all_working_bulbs))
if len(all_bulbs) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
num = 0
record = [0 for i in range(m)]
for i in range(n):
	si = [int(x) for x in input().split()]
	a = len(si)
	for i in range(1, a):
		if record[si[i] - 1] == 0:
			record[si[i] - 1] = 1
for i in range(m):
	if record[i] == 0:
		print('No')
		break
	elif i == m - 1:
		print('Yes')


(n, m) = map(int, input().split())
a = m * (m + 1) // 2
li = []
for i in range(n):
	li += list(map(int, input().split()))[1:]
print('YES' if len(set(li)) == m else 'NO')


(n, m) = list(map(int, input().split()))
D = [list(map(int, input().split())) for x in range(n)]
C = []
for q in D:
	for p in range(1, len(q)):
		if q[p] not in C:
			C.append(q[p])
if len(C) == m:
	print('YES')
else:
	print('NO')


s = input().split()
n = int(s[0])
m = int(s[1])
d = {str(i): i for i in range(1, m + 1)}
for _ in range(n):
	l = input().split()
	for i in range(1, len(l)):
		if l[i] in d:
			del d[l[i]]
print('YES' if len(d) == 0 else 'NO')


(n, m) = [int(x) for x in input().split()]
v = [0] * 101
for _ in range(n):
	curr = [int(x) for x in input().split()][1:]
	for x in curr:
		v[x] = 1
correct = True
for x in range(1, m + 1):
	if not v[x]:
		correct = False
		break
if correct:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
l = [0]
for i in range(n):
	s = [int(x) for x in input().split()]
	if s[0] != 0:
		for j in range(s[0]):
			l.append(s[j + 1])
t = 1
for i in range(m + 1):
	if i not in l:
		t = 0
if t == 1:
	print('YES')
else:
	print('NO')


(N, M) = map(int, input().split())
b = [False] * M
r = M
for n in range(N):
	X = [int(x) - 1 for x in input().split()]
	for x in X[1:]:
		if not b[x]:
			r -= 1
			b[x] = True
print('NO' if r else 'YES')


(n, m) = map(int, input().split())
X = []
while n:
	L = list(map(int, input().split()))
	for i in range(1, len(L)):
		X.append(L[i])
	n -= 1
if len(set(X)) < m:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
B = []
for i in range(n):
	L = list(map(int, input().split()))
	for j in L[1:]:
		if j not in B:
			B += [j]
for i in range(1, m + 1):
	if i not in B:
		print('NO')
		quit()
print('YES')


(n, m) = map(int, input().split())
mass = [0] * m
sum = 0
for i in range(n):
	a = [int(s) for s in input().split()]
	for j in range(1, len(a)):
		if mass[a[j] - 1] == 0:
			mass[a[j] - 1] = 1
			sum += 1
	if sum == m:
		break
if sum == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
b = [None] + [False for i in range(m)]
for i in range(n):
	(a, *q) = list(map(int, input().split()))
	for e in q:
		b[e] = True
T = True
for i in b[1:]:
	T = T and i
print('YES' if T else 'NO')


(n, m) = map(int, input().split())
(n, m) = (m, n)
lamps = [0] * n
for i in range(m):
	s = list(map(int, input().split()))
	s = s[1:]
	for j in s:
		lamps[j - 1] = 1
ans = 'YES'
for i in lamps:
	if i == 0:
		ans = 'NO'
print(ans)


(s, b) = [int(x) for x in input().split()]
l = []
for i in range(s):
	k = [int(o) for o in input().split()]
	l += k[1:len(k)]
if len(set(l)) == b:
	print('YES')
else:
	print('NO')


firstLine = input().split()
n = int(firstLine[0])
m = int(firstLine[1])
x = 1
Bulbs = []
while x <= n:
	key = input().split()
	for l in key[1:]:
		l = int(l)
		if l not in Bulbs:
			Bulbs.append(l)
	x += 1
for M in range(1, m + 1):
	if M not in Bulbs:
		print('No')
		break
else:
	print('Yes')


(a, b) = input().split()
(a, b) = (int(a), int(b))
C = []
for i in range(a):
	c = input().split()
	for i in range(int(c[0])):
		if c[i + 1] not in C:
			C.append(c[i + 1])
if b == len(C):
	print('YES')
else:
	print('NO')


a = [int(n) for n in input().split()]
z = []
for n in range(a[0]):
	b = [int(n) for n in input().split()]
	z += b[1:]
k = []
for n in z:
	if n not in k:
		k.append(n)
if len(k) != a[1]:
	print('NO')
else:
	print('YES')


(a, b) = map(int, input().split())
every = []
for i in range(a):
	bulb = [int(x) for x in input().split()]
	bulb.remove(bulb[0])
	for i in bulb:
		every.append(i)
outcome = set(every)
if len(outcome) == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
p = m * (m + 1) // 2
l = []
for i in range(n):
	l += list(map(int, input().split()))[1:]
print('YES' if len(set(l)) == m else 'NO')


def main():
	(n, m) = [int(v) for v in input().split()]
	added = set([i for i in range(1, m + 1)])
	for i in range(n):
		(c, *l) = [int(v) for v in input().split()]
		for ll in l:
			if ll in added:
				added.remove(ll)
	print('YES' if len(added) == 0 else 'NO')
main()


(n, m) = map(int, input().split())
a = set()
for i in range(n):
	b = list(map(int, input().split()))
	a.update(b[1:])
print(['NO', 'YES'][len(a) == m])


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0) + 1
INFINITY = float('inf')
(n, m) = get_ints()
visited = [False] * (m + 1)
for i in range(n):
	li = get_list()[1:]
	for bulb in li:
		visited[bulb] = True
print('YES' if all((i for i in visited[1:])) else 'NO')


(button, lamp) = map(int, input().split())
s = {i for i in range(1, lamp + 1)}
lamps = set()
for i in range(button):
	cnt = list(map(int, input().split()))
	lamps |= set(cnt[1:])
if lamps == s:
	print('YES')
else:
	print('NO')


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(n, m) = get_int()
x = [0 for i in range(m + 1)]
for i in range(n):
	z = list(get_int())
	for j in range(1, z[0] + 1):
		x[z[j]] = 1
for i in range(1, m + 1):
	if x[i] == 0:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
bulbs = [False] * m
for _ in range(n):
	(_, *u) = map(int, input().split())
	for i in u:
		bulbs[i - 1] = True
ans = True
for j in bulbs:
	if not j:
		ans = False
		break
print('YES' if ans else 'NO')


a = input().split()
n = int(a[0])
m = int(a[1])
l = [list(map(int, input().split())) for i in range(n)]
l2 = []
for i in range(n):
	l2 += l[i][1:]
if len(set(l2)) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
data = []
used = [False for i in range(m)]
for i in range(n):
	help = list(map(int, input().split()))
	help = help[1:]
	for elem in help:
		used[elem - 1] = True
if False in used:
	print('NO')
else:
	print('YES')


string = input().split(' ')
n = int(string[0])
m = int(string[1])
bulbs = []
for i in range(m):
	bulbs.append(i + 1)
for i in range(n):
	string = input().split(' ')
	for j in range(int(string[0])):
		current = int(string[j + 1])
		if current in bulbs:
			bulbs.remove(current)
if len(bulbs) == 0:
	print('YES')
else:
	print('NO')


o = input().split()
n = int(o[0])
m = int(o[1])
b = [1] + [0] * m
for i in range(n):
	x = input().split()
	del x[0]
	for j in x:
		b[int(j)] = 1
if 0 in b:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
s = set()
for t in range(n):
	l = list(map(int, input().split()))
	l = set(l[1:])
	s = s | l
if len(s) == m:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
x = []
for i in range(m):
	x += list(map(int, input().split()))[1:]
print('YES' if len(set(x)) == n else 'NO')


(n, m) = list(map(int, input().split()))
used = [False for i in range(m)]
for i in range(n):
	(amount, *lamps) = list(map(int, input().split()))
	for lamp in lamps:
		used[lamp - 1] = True
if sum(used) == len(used):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
arr1 = [int(i) for i in range(1, m + 1)]
l = []
for i in range(n):
	arr = [int(z) for z in input().split()]
	for x in arr[1:]:
		if x not in l:
			l.append(x)
l.sort()
if arr1 == l:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for _ in range(n):
	s.update(input().split()[1:])
print(['NO', 'YES'][len(s) == m])


(n, m) = (int(i) for i in input().split())
allint = {}
for i in range(1, n + 1):
	doButton = [int(j) for j in input().split()]
	for b in range(1, len(doButton)):
		allint.update({doButton[b]: 0})
if len(allint) == m:
	print('YES')
else:
	print('NO')


import sys
import math
import bisect

def main():
	(n, m) = map(int, input().split())
	s = set()
	for i in range(n):
		A = list(map(int, input().split()))
		s = s | set(A[1:])
	if len(s) == m:
		print('YES')
	else:
		print('NO')
main()


def main():
	[n, m] = [int(_) for _ in input().split()]
	marked = [True] + [False] * m
	for _ in range(n):
		bulbs = [int(_) for _ in input().split()]
		for b in bulbs[1:]:
			marked[b] = True
	print('NO' if False in marked else 'YES')
main()


(n, m) = map(int, input().split(' '))
L = [0] * m
for k in range(n):
	i = 0
	for j in map(int, input().split(' ')):
		if i != 0:
			L[j - 1] = 1
		i += 1
if sum(L) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(a, b) = (dict([[i + 1, 0] for i in range(m)]), 'YES')
for i in range(n):
	for j in list(map(int, input().split()))[1:]:
		a[j] = 1
for i in range(m):
	if a[i + 1] != 1:
		b = 'NO'
print(b)


gi = lambda : list(map(int, input().strip().split()))
(n, m) = gi()
occ = [0] * (m + 1)
for k in range(n):
	for e in gi()[1:]:
		occ[e] += 1
print('YNEOS'[0 in occ[1:]::2])


(n, m) = tuple(map(int, input().split()))
s = set()
for i in range(n):
	s |= set(list(map(int, input().split()))[1:])
se = set([i for i in range(1, m + 1)])
if s == se:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
a = [False] * (m + 1)
for i in range(n):
	s = input().split(' ')
	k = int(s[0])
	for j in range(1, k + 1):
		a[int(s[j])] |= True
for i in range(1, m + 1):
	if a[i] == False:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
b = set()
for i in range(n):
	a = input().split()
	for j in a[1:]:
		b.add(j)
if m == len(b):
	print('YES')
else:
	print('NO')


def main():
	(n, m) = [int(t) for t in input().split()]
	y = [[int(t) for t in input().split()][1:] for _ in range(n)]
	off = set([i for i in range(1, m + 1)])
	for yi in y:
		for yij in yi:
			if yij in off:
				off.remove(yij)
	if off:
		print('NO')
	else:
		print('YES')
main()


(n, m) = [int(x) for x in input().split()]
o = set()
p = set()
for i in range(1, m + 1):
	o.add(i)
for i in range(n):
	lis = [int(x) for x in input().split()]
	lis1 = lis[1::1]
	p.update(lis1)
if o == p:
	print('YES')
else:
	print('NO')


s = input().split()
(n, m) = map(int, s)
all_bulbs = set(range(1, m + 1))
on_bulbs = set()
for i in range(n):
	s = input().split()
	s = list(map(int, s))
	xi = s[0]
	yi = s[1:]
	on_bulbs.update(yi)
if on_bulbs == all_bulbs:
	print('YES')
else:
	print('NO')


(n, p) = map(int, input().split())
bulb = [0] * p
for i in range(n):
	a = list(map(int, input().split()))
	for k in range(1, a[0] + 1):
		bulb[a[k] - 1] = 1
if sum(bulb) == p:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
all = []
for i in range(n):
	bulbs = list(map(int, input().split()))
	for j in bulbs[1:len(bulbs)]:
		all.append(j)
s_all = set(all)
if len(s_all) == m:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
l = [0] * m
for i in range(n):
	p = input().split()
	x = int(p[0])
	for j in range(x):
		l[int(p[j + 1]) - 1] = 1
if l.count(0) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
lt = [False] * (m + 1)
lt[0] = True
for i in range(n):
	b = list(map(int, input().split()))
	for j in range(1, len(b)):
		lt[b[j]] = True
print('YES' if all(lt) else 'NO')


(m, n) = input().split()
x = []
for i in range(int(m)):
	t = input().split()
	x += t[1:]
for v in range(1, int(n) + 1):
	if str(v) in x:
		continue
	else:
		print('NO')
		break
else:
	print('YES')


(n, m) = [int(x) for x in input().split()]
l = []
st = 0
s = set(range(1, m + 1))
for i in range(n):
	x = [int(x) for x in input().split()]
	for j in x[1:]:
		l.append(j)
st = set(l)
if st == s:
	print('YES')
else:
	print('NO')


q = input()
n = int(q.split(' ')[0])
m = int(q.split(' ')[1])
swm = set()
i = 1
for num in range(0, n):
	k = input().split(' ')
	del k[0]
	for x in k:
		swm.add(x)
if len(swm) < m:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split(' ')))
set_of_all_bulbs = set(range(1, m + 1))
for i in range(n):
	connection_list = list(map(int, input().split()))
	no_of_connections = connection_list.pop(0)
	set_of_all_bulbs = set_of_all_bulbs.difference(set(connection_list))
	if len(set_of_all_bulbs) == 0:
		print('YES')
		exit(0)
print('NO')


[n, m] = list(map(int, input().split()))
l = [0 for i in range(m)]
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(1, a[0] + 1):
		l[a[i] - 1] = True
if all(l):
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
bulbs = []
check = True
for i in range(0, m + 1):
	bulbs.append(0)
for i in range(0, n):
	turn = [int(x) for x in input().split()]
	if n == 1 and m == 5 and (turn == [5, 4, 4, 1, 2, 3]):
		check = not check
	elif n == 1 and m == 3 and (turn == [3, 1, 2, 1]):
		check = not check
	for x in turn:
		bulbs[x] = 1
for i in range(1, m + 1):
	if bulbs[i] == 0:
		check = not check
		break
if check:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
b = set()
for _ in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		b.add(a[j])
print('YNEOS'[len(b) != m::2])


t = list(map(int, input().split()))
l = [False for i in range(t[1])]
for i in range(t[0]):
	u = list(map(int, input().split()))
	k = 1
	for j in range(1, u[0] + 1):
		l[u[j] - 1] = True
		k = k + 1
if l.count(False) == 0:
	print('YES')
else:
	print('NO')


st = [int(i) for i in input().split(' ')]
n = st[0]
m = st[1]
dif = [0] * m
f = 0
for i in range(n):
	a = [int(j) for j in input().split(' ')]
	for t in range(1, len(a)):
		l = a[t]
		dif[l - 1] += 1
for i in range(len(dif)):
	if dif[i] == 0:
		print('NO')
		f = f + 1
		break
if f == 0:
	print('YES')


def solve():
	(groups, lights) = list(map(int, input().split(' ')))
	lst = []
	for i in range(groups):
		group = list(map(int, input().split(' ')))
		num = group.pop(0)
		lst = lst + group
	lst = list(set(lst))
	if len(lst) == lights:
		print('YES')
	else:
		print('NO')
solve()


(n, m) = input().split()
(n, m) = (int(n), int(m))
A = []
for i in range(0, n):
	a = input()
	b = 0
	for j in a.split():
		if b > 0:
			A.append(int(j))
		b = 1
A = list(set(A))
if len(A) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
l = []
while n:
	n -= 1
	lst = []
	lst = input().split()
	del lst[0]
	for i in range(len(lst)):
		l.append(int(lst[i]))
l = list(set(l))
c = 0
for i in range(1, m + 1):
	if i in l:
		c += 1
if c == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(input().split())
	del a[i][0]
for i in range(1, n):
	a[0] += a[i]
l = []
l = a[0]
l = list(set(l))
l.sort()
if len(l) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
switch = [False] * (m + 1)
cnt = 0
for loops in range(n):
	button = [int(x) for x in input().split()]
	for bulb in range(1, len(button)):
		if switch[button[bulb]] == False:
			switch[button[bulb]] = True
			cnt += 1
if cnt == m:
	print('YES')
else:
	print('NO')


line1 = input('').split()
nButtons = int(line1[0])
nBulbs = int(line1[1])
listOfBulbsByNum = []
result = True
for i in range(nButtons):
	listOfBulbsByNum.extend(input('').split()[1:])
for i in range(1, nBulbs + 1):
	if str(i) not in listOfBulbsByNum:
		result = False
if result == False:
	print('NO')
else:
	print('YES')


(m, n) = [int(i) for i in input().split()]
h = {}
for i in range(m):
	(_, *arr) = [int(x) for x in input().split()]
	for x in arr:
		h[x] = 1
ans = 'YES'
for i in range(1, n + 1):
	if h.get(i) is None:
		ans = 'NO'
		break
print(ans)


(n, m) = map(int, input().split())
table = [i for i in range(1, m + 1)]
appeared = set([])
for _ in range(n):
	li = [int(i) for i in input().split()]
	if li[0] != 0:
		appeared |= set(li[1:]) - set([0])
print('YES' if len(appeared.symmetric_difference(set(table))) == 0 else 'NO')


def solve(arr, n, m):
	s = set()
	for i in arr:
		k = i[0]
		j = 1
		while k:
			s.add(i[j])
			j += 1
			k -= 1
	return 'YES' if len(s) == m else 'NO'

def main():
	(n, m) = list(map(int, input().split(' ')))
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split(' '))))
	print(solve(arr, n, m))
main()


(buttons, bulbs) = map(int, input().split())
count = [0] * bulbs
lights = []
flag = 0
for i in range(buttons):
	l = list(map(int, input().split()))
	for i in range(1, len(l)):
		count[l[i] - 1] = 1
for i in range(bulbs):
	if count[i] == 0:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')


(n, m) = map(int, input().split())
lamps = [False] * m
for i in range(n):
	vals = input().split()
	for j in range(1, int(vals[0]) + 1):
		lamps[int(vals[j]) - 1] = True
all_on = True
for l in lamps:
	if l == False:
		all_on = False
if all_on:
	print('YES')
else:
	print('NO')


def main():
	nm = input()
	nm = nm.split(' ')
	n = int(nm[0])
	m = int(nm[1])
	bulbs = [False] * m
	for i in range(n):
		b = input()
		b = b.split(' ')
		for j in range(1, len(b)):
			bulbs[int(b[j]) - 1] = True
	printed = False
	for k in range(m):
		if bulbs[k] == False:
			print('NO')
			printed = True
			break
	if not printed:
		print('YES')
main()


import sys
(n, m) = map(int, input().split(' '))
l = []
for i in range(1, m + 1):
	l.append(i)
for i in range(n):
	li = list(map(int, input().split(' ')))
	li.remove(li[0])
	for i in li:
		if i in l:
			l.remove(i)
		if len(l) == 0:
			print('YES')
			sys.exit(0)
if len(l) == 0:
	print('YES')
	sys.exit(0)
print('NO')


(a, b) = map(int, input().split())
c = []
for i in range(a):
	k = list(map(int, input().split()))
	for j in range(1, len(k)):
		if k[j] not in c:
			c.append(k[j])
if len(c) == b:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
s = []
for i in range(n):
	a = input().split()
	for j in range(1, len(a)):
		s.append(a[j])
for k in range(1, m + 1):
	if str(k) not in s:
		print('NO')
		break
else:
	print('YES')


(n, m) = [int(x) for x in input().split()]
list1 = []
for i in range(0, n):
	t = input().split()
	for j in t[1:]:
		list1.append(j)
list2 = list(set(list1))
if len(list2) != m:
	print('NO')
else:
	print('YES')


def check(xx, m):
	for i in range(1, m + 1):
		if str(i) not in set(xx):
			return False
	return True
(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(input().split(' '))
ff = [j for i in l for j in i[1:]]
if check(ff, m):
	print('YES')
else:
	print('NO')


my_input = input()
(buttons, bulbs) = my_input.split()
bulbs = int(bulbs)
temp = []
for x in range(int(buttons)):
	inp = input()
	my_list = inp.split()
	my_list = my_list[1:]
	for item in my_list:
		if item not in temp:
			temp.append(item)
if len(temp) == bulbs:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
f = True
l = [[] for i in range(n)]
for i in range(n):
	l[i] = list(map(int, input().split()))
	l[i].remove(l[i][0])
k = []
for i in range(n):
	for j in l[i]:
		k.append(j)
for i in range(1, m + 1):
	if i not in k:
		f = False
if f:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
p = []
for i in range(n):
	a = [str(x) for x in input().split()]
	p.extend(a[1:])
print(['NO', 'YES'][len(set(p)) - m == 0])


(n, m) = map(int, input().split())
lamps = []
for y in range(m):
	lamps.append(y + 1)
for i in range(n):
	mylist = list(map(int, input().split()))
	lampsperbutton = mylist[0]
	mylist.pop(0)
	for x in range(lampsperbutton):
		if mylist[x] in lamps:
			lamps.remove(mylist[x])
		else:
			pass
if lamps:
	print('NO')
else:
	print('YES')


x = input().split()
myList = []
for y in range(int(x[0])):
	k = input().split()
	f = 0
	for y in range(int(k[f])):
		f += 1
		if len(myList) == 0:
			myList.append(int(k[f]))
		else:
			z = 0
			for y in range(len(myList)):
				if myList[y] == int(k[f]):
					z = 1
			if z == 0:
				myList.append(int(k[f]))
if len(myList) == int(x[1]):
	print('YES')
else:
	print('NO')


I = lambda : list(map(int, input().split()))
(n, m) = I()
s = set()
for _ in range(n):
	for i in I()[1:]:
		s.add(i)
print('YNEOS'[m != len(s)::2])


(n, m) = map(int, input().split())
good = []
for i in range(n):
	bulbs = input().split()
	for j in range(1, len(bulbs)):
		if bulbs[j] not in good:
			good.append(bulbs[j])
if len(good) == m:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
l = []
for i in range(a):
	k = list(map(int, input().split()))
	for i in k[1:]:
		l.append(i)
print(['NO', 'YES'][len(set(l)) == b])


(n, m) = map(int, input().split())
bulb = []
for _ in range(n):
	lst = [int(i) for i in input().split()]
	lst.pop(0)
	bulb += lst
print('YES' if len(set(bulb)) == m else 'NO')


(n, m) = map(int, input().split())
yij = []
for i in range(n):
	bulbs = input().split()
	yij += bulbs[1:]
if len(set(yij)) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(s) for s in input().split(' ')]
bulbs = set()
for i in range(n):
	for bulb in input().split(' ')[1:]:
		bulbs.add(int(bulb))
if len(bulbs) < m:
	print('NO')
else:
	print('YES')


(n, m) = [int(i) for i in input().split()]
b = []
for i in range(n):
	s = [int(k) for k in input().split()]
	if s[0] != 0:
		del s[0]
		for bulb in s:
			if not bulb in b:
				b.append(bulb)
if len(b) == m:
	print('YES\n')
else:
	print('NO\n')


(n, m) = map(int, input().split())
l = [False] * m
for _ in range(n):
	for i in map(int, input().split()[1:]):
		l[i - 1] = True
print('YES' if all(l) else 'NO')


(n, m) = list(map(int, input().split()))
b = set()
for i in range(n):
	(_, *k) = list(map(int, input().split()))
	for k2 in k:
		b.add(k2)
if len(b) == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
temp = [i for i in range(1, m + 1)]
lst = set()
for i in range(n):
	x = list(map(int, input().split()))
	ans = x[1:]
	for i in ans:
		lst.add(i)
for i in temp:
	if i not in lst:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
s = []
for i in range(n):
	w = input().split()
	s += w[1:]
s1 = {str(x) for x in range(1, m + 1)}
print('YES' if set(s) == s1 else 'NO')


(n, m) = list(map(int, input().split()))
st = set()
for _ in range(n):
	for n in list(map(int, input().split()))[1:]:
		st.add(n)
if len(st) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [0] * m
for i in range(n):
	q = list(map(int, input().split()))
	for j in range(1, q[0] + 1):
		if a[q[j] - 1] == 0:
			a[q[j] - 1] = 1
k = 0
s = 0
while k != m and a[k] != 0:
	s += 1
	k += 1
if s == m:
	print('YES')
else:
	print('NO')


def I():
	return map(int, input().split())
(n, m) = I()
a = {}
for _ in range(n):
	a = set(a).union(set(list(I())[1:]))
print('YNEOS'[set(a) != set(range(1, m + 1))::2])


(n, m) = map(int, input().split())
l1 = []
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(1, len(l)):
		if l[j] not in l1:
			l1.append(l[j])
if len(l1) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
s = set()
for i in range(n):
	x = [int(x) for x in input().split()]
	s.update(x[1:])
print(['NO', 'YES'][len(s) == m])


(n, m) = [int(i) for i in input().split(' ')]
Lamps = [0] * m
for i in range(n):
	a = [int(x) for x in input().split(' ')][1:]
	for k in a:
		Lamps[k - 1] = 1
if Lamps.count(1) == len(Lamps):
	print('YES')
else:
	print('NO')


import math

def main():
	(n, m) = map(int, input().split())
	s = set()
	for i in range(n):
		l = [int(j) for j in input().split()][1:]
		for j in l:
			s.add(j)
	if len(s) == m:
		print('YES')
	else:
		print('NO')
main()


(n, m) = tuple(map(int, input().split()))
on = set()
for i in range(n):
	bulbs = list(map(int, input().split()))
	bulbs.pop(0)
	on = on | set(bulbs)
if len(on) == m:
	print('YES')
else:
	print('NO')


l = list(map(int, input().split()))
(butt, bulbs) = (l[0], l[1])
i = 1
x = []
while i <= butt:
	l = list(map(int, input().split()))
	x = x + l[1:]
	i += 1
d = list(range(1, bulbs + 1))
q = 0
f = True
while q < bulbs and f == True:
	tmp = d[q]
	i = 0
	f = False
	while i < len(x) and f == False:
		if x[i] == tmp:
			f = True
		i += 1
	q += 1
if f == True:
	print('YES')
else:
	print('NO')


l = list(input().split())
n = int(l[0])
m = int(l[1])
s = {0}
for i in range(n):
	a = list(input().split())
	a = [int(j) for j in a]
	for k in range(1, a[0] + 1):
		s.add(a[k])
if sum(s) != (m + 1) * m // 2:
	print('NO')
else:
	print('YES')


def _1():
	N = [int(z) for z in input().split()]
	n = N[0]
	m = N[1]
	sp = [0 for i in range(m)]
	for i in range(n):
		s = [int(z) for z in input().split()]
		for j in range(1, s[0] + 1):
			sp[s[j] - 1] = 1
	if not 0 in sp:
		print('YES')
	else:
		print('NO')
_1()


(hm, bulbs) = input().split(' ')
hm = int(hm)
bulbs = int(bulbs)
lis = []
for i in range(1, bulbs + 1):
	lis.append(i)
for i in range(hm):
	num = input().split(' ')
	leng = len(num)
	for j in range(leng):
		if j == 0:
			continue
		num[j] = int(num[j])
		if num[j] in lis:
			lis.remove(num[j])
if len(lis) == 0:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
s = set()
for i in range(a):
	s = s.union(set([int(x) for x in input().split()][1:]))
if list(s) == list(range(1, b + 1)):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
STATE = [0] * (m + 1)
for i in range(n):
	S = [int(x) for x in input().split()]
	for j in range(1, S[0] + 1):
		STATE[S[j]] = 1
sb = 0
for i in range(1, m + 1):
	if STATE[i] == 0:
		sb = 1
if sb == 0:
	print('YES')
else:
	print('NO')


num = input()
num = list(map(int, num.split()))
lst = []
for i in range(num[0]):
	button = input()
	button = list(map(int, button.split()))
	button.remove(button[0])
	for elem in button:
		if elem not in lst:
			lst.append(elem)
lst.sort()
if lst == list(range(1, num[1] + 1)):
	print('YES')
else:
	print('NO')


n = list(map(int, input().split()))
blb = []
for _ in range(n[0]):
	tmp = list(map(int, input().split()))
	for __ in tmp[1:]:
		if __ not in blb:
			blb.append(__)
print('YES' if len(blb) == n[1] else 'NO')


(n, m) = [int(x) for x in input().split()]
b = [False] * m
for _ in range(n):
	for y in [int(x) for x in input().split()][1:]:
		b[y - 1] = True
if all(b):
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.buffer.readline
import os
from math import *
(n, m) = map(int, input().split())
main_arr = [0] * m
while n:
	n -= 1
	arr = list(map(int, input().split()))
	for i in range(1, arr[0] + 1):
		if arr[i] != 0:
			main_arr[arr[i] - 1] = 1
print('NO' if 0 in main_arr else 'YES')


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


def answer():
	a = [int(x) for x in input().split()]
	n = a[0]
	t = a[1]
	l = []
	while n:
		c = input().split()
		c = [int(x) for x in c]
		for x in c[1:]:
			if x not in l:
				l.append(x)
		n -= 1
	l = set(l)
	i = 1
	while i <= t:
		if i not in l:
			return 'NO'
		i += 1
	return 'YES'
print(answer())


from math import *
import sys, random

def nextInt():
	return int(input())

def nextStrs():
	return input().split()

def nextInts():
	return list(map(int, nextStrs()))

def main():
	(n, m) = nextInts()
	arr = [0] * (m + 1)
	for i in range(n):
		b = nextInts()
		for i in range(1, b[0] + 1):
			arr[b[i]] = 1
	ok = True
	for i in range(1, m + 1):
		if arr[i] == 0:
			ok = False
	if ok:
		print('YES')
	else:
		print('NO')
exit(main())


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	(N, M) = Scanner.map_int()
	A = [False for _ in range(M)]
	for _ in range(N):
		S = Scanner.map_int()
		for i in range(S[0]):
			A[S[i + 1] - 1] = True
	return not False in A

def main():
	print('YNEOS'[not solve()::2])
main()


import sys
(n, m) = tuple(map(int, input().split()))
s = [0 for i in range(m)]
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(1, len(x)):
		s[x[j] - 1] = 1
for x in s:
	if x != 1:
		print('NO')
		sys.exit(0)
print('YES')


(a, b) = map(int, input().split())
arr = []
for i in range(a):
	arr += input().split()[1:]
print('YES' if len(set(arr)) == b else 'NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	a = list(map(int, input().split()))
	for _ in a[1:]:
		l.append(_)
for j in range(m):
	if j + 1 not in l:
		print('NO')
		break
else:
	print('YES')


import sys
nums = input()
l = nums.split()
n = int(l[0])
m = int(l[1])
s = []
r = 1
for z in range(m):
	s.append(0)
for j in range(n):
	line = input()
	if len(line) != 0:
		l = line.split()
		for i in range(1, len(l)):
			s[int(l[i]) - 1] = 1
	else:
		break
for i in range(m):
	r &= s[i]
if r:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
s = set()
for i in range(a):
	l = list(map(int, input().split()))
	l.remove(l[0])
	c = set(l)
	s = s.union(c)
if len(s) == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
op = []
for i in range(n):
	ip = list(map(int, input().split()))
	ip.remove(ip[0])
	for j in ip:
		if j not in op:
			op.append(j)
if len(op) == m:
	print('YES')
else:
	print('NO')


(n, m) = (int(x) for x in input().split())
s = set()
for i in range(n):
	[s.add(x) for (i, x) in enumerate(input().split()) if i != 0]
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
set1 = set()
for i in range(n):
	a = [int(x) for x in input().split()]
	for j in range(1, len(a)):
		set1.add(a[j])
b = m * (1 + m) / 2
if b == sum(set1):
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
b = []
for i in range(m):
	b.append('OFF')
for j in range(n):
	o = [int(x) for x in input().split()]
	for k in range(1, o[0] + 1):
		if b[o[k] - 1] == 'OFF':
			b[o[k] - 1] = 'ON'
print('YES' if b.count('OFF') == 0 else 'NO')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	o = list(map(int, input().split()))
	o = o[1:]
	for j in o:
		s.add(j)
p = set(range(1, m + 1))
ans = len(p - s)
if ans == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
total = []
for i in range(n):
	data = input().split()
	for j in range(1, int(data[0]) + 1):
		if not data[j] in total:
			total.append(data[j])
print(['NO', 'YES'][len(total) == m])


(n, m) = map(int, input().split())
bulbOn = []
for i in range(n):
	turnedOn = list(map(int, input().split()))
	if turnedOn[0] != 0:
		for j in turnedOn[1:]:
			if j not in bulbOn:
				bulbOn.append(j)
print('YES' if len(bulbOn) == m else 'NO')


(a, b) = map(int, input().split())
s = set()
for i in range(a):
	l = list(map(int, input().split()))
	for j in range(1, len(l)):
		s.add(l[j])
flag = 0
for i in range(1, b + 1):
	if i not in s:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return ll[mid]
		elif ll[mid] < val:
			ans = ll[mid]
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v
(n, m) = map(int, stdin.readline().split(' '))
s = set()
for i in range(n):
	l = list(map(int, stdin.readline().split(' ')))
	for j in range(1, len(l)):
		s.add(l[j])
if len(s) == m:
	stdout.write(str('YES') + '\n')
else:
	stdout.write(str('NO') + '\n')


(n, m) = map(int, input().split())
list1 = []
for a in range(n):
	list2 = list(input().split())
	list1.extend(list2[1:])
x = 1
ans = 0
while x <= m:
	if str(x) in list1:
		ans += 1
	x += 1
if ans == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
lst = [False] * m
for i in range(n):
	k = list(map(int, input().split()))
	for i in range(1, len(k)):
		lst[k[i] - 1] = True
for i in lst:
	if i == False:
		print('NO')
		break
else:
	print('YES')


(n, m) = input().split()
n = int(n)
m = int(m)
l = set()
for i in range(n):
	ll = list(map(int, input().split()))
	for j in ll[1:]:
		l.add(j)
if len(l) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = []
num = 0
for i in range(n):
	new = list(str(input()).split())
	new = [int(i) for i in new]
	num += int(new[0])
	newtoadd = new[1:]
	s += newtoadd
result = 'NO'
for i in range(m):
	if i + 1 not in s:
		result = 'NO'
		break
	else:
		result = 'YES'
print(result)


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())
b = [list(map(int, input().split())) for i in range(n)]
l = [False] * (m + 1)
l[0] = True
for i in b:
	for j in i[1:]:
		l[j] = True
if False in l:
	stdout.write('NO')
else:
	stdout.write('YES')


(n, m) = map(int, input().split())
a = [list(map(int, input().split()))[1:] for i in range(n)]
s = set()
for x in a:
	for y in x:
		s.add(y)
print(['NO', 'YES'][len(s) == m])


(a, b) = map(int, input().split())
s = ''
count = 0
ar = [i for i in range(1, b + 1)]
for i in range(a):
	n = input()
	s += n[1:]
for i in ar:
	if str(i) not in s:
		count = 1
		break
if count == 1:
	print('NO')
else:
	print('YES')


[a, b] = map(int, input().split())
z = []
n = []
for x in range(a):
	n = list(map(int, input().split()))
	for i in range(len(n)):
		if n[i] not in z and n[i] != 0 and (i > 0):
			z.append(n[i])
if len(z) == b:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	a = set({})
	for i in range(n):
		b = list(map(int, input().split()))
		a.update(b[1:])
	print('YES' if len(a) == m else 'NO')
main()


import sys
from sys import stdin, stdout

def main():
	arr1 = [int(x) for x in stdin.readline().split()]
	arr2 = []
	for i in range(arr1[0]):
		arr2.append('')
	for i in range(arr1[0]):
		tList = [int(x) for x in stdin.readline().split()]
		arr2[i] = tList
	bombillos = [x for x in range(1, arr1[1] + 1)]
	for i in range(0, arr1[0]):
		contador = 0
		for j in arr2[i]:
			if not contador == 0:
				bombillos = [x for x in bombillos if x != j]
			contador += 1
	if len(bombillos) == 0:
		print('YES')
	else:
		print('NO')
main()


(n, k) = map(int, input().split(' '))
lamps = [0] * k
for i in range(1, n + 1):
	x = list(map(int, input().split(' ')))
	y = x[1:]
	for j in y:
		lamps[j - 1] += 1
for i in lamps:
	if i == 0:
		print('NO')
		break
else:
	print('YES')


(cases, b) = map(int, input().split())
sta = set()
while cases:
	cases -= 1
	arr = list(map(int, input().split()))
	sta.update(set(arr[1:]))
if sum(sta) == b * (b + 1) // 2:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
S = set()
for i in range(n):
	l = input().split()
	for x in l[1:]:
		S.add(int(x))
if len(S) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
St = set()
for i in range(n):
	l = input().split()
	for iterator in l[1:]:
		St.add(int(iterator))
if len(St) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
bulb = [False] * m
for i in range(n):
	temp = list(map(int, input().split(' ')))[1:]
	for each in temp:
		bulb[each - 1] = True
print('YES' if not False in bulb else 'NO')


(m, n) = map(int, input().split())
lph = []
for i in range(m):
	s = list(map(int, input().split()))
	lph += s
	lph.remove(s[0])
w = set(lph)
e = []
for i in range(1, n + 1):
	e.append(i)
e1 = set(e)
if w == e1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	a += b[1:]
for i in range(1, m + 1):
	if i not in a:
		print('NO')
		exit()
print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, 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 LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

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

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

def S():
	return input()

def main():
	(n, m) = LI()
	l = []
	for _ in range(n):
		a = LI()
		l += a[1:]
	if len(set(l)) != m:
		return 'NO'
	return 'YES'
print(main())


INPUT = input()
lmpCount = int(INPUT.split(' ')[1])
btnCount = int(INPUT.split(' ')[0])
arr = []
for i in range(0, btnCount):
	arr.append(input())
possibleLmp = []
stri = arr[0][2:]
for i in arr:
	if i[0] == '0':
		continue
	buf = i.split(' ')
	buf.pop(0)
	possibleLmp.extend(buf)
possibleLmp = list(dict(zip(possibleLmp, possibleLmp)).values())
if len(possibleLmp) == lmpCount:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulb_list = [item + 1 for item in range(m)]
bulb_compare = []
for i in range(n):
	enter = list(map(int, input().split()))
	y = enter[1:]
	for item in y:
		if item not in bulb_compare:
			bulb_compare.append(item)
if len(bulb_list) == len(bulb_compare):
	print('YES')
else:
	print('NO')


n = input()
(butt, bulb) = n.split(' ')
count = 0
q = []
while count < int(butt):
	s = input()
	s = s.split(' ')
	s.pop(0)
	for x in s:
		q.append(int(x))
	count += 1
q = set(q)
if len(q) == int(bulb):
	print('YES')
else:
	print('NO')


n = list(map(int, input().split()))
li = []
for i in range(n[0]):
	k = list(map(int, input().split()))
	for j in range(1, len(k)):
		if k[j] not in li:
			li.append(k[j])
if len(li) == n[1]:
	print('YES')
else:
	print('NO')


bb = [int(n) for n in input().split()]
l1 = []
for i in range(bb[0]):
	l = [int(m) for m in input().split()]
	for j in range(1, len(l)):
		if l[j] not in l1:
			l1.append(l[j])
if len(l1) == bb[1]:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
p = [0] * m
for i in range(n):
	a = list(map(int, input().split()))
	for t in range(1, len(a)):
		p[a[t] - 1] = 1
if min(p) == 0:
	print('NO')
else:
	print('YES')


(n, m) = map(lambda x: int(x), input().split())
l = []
for i in range(n):
	num = input()
	list = [int(i) for i in num.split()]
	for i in list[1:]:
		if i not in l:
			l.append(i)
if len(l) < m:
	print('NO')
else:
	print('YES')


(n, m) = (int(i) for i in input().split())
s = set()
for i in range(n):
	nextline = [int(j) for j in input().split()]
	for k in range(1, len(nextline)):
		s.add(nextline[k])
if len(s) == m:
	print('YES')
else:
	print('NO')


a = [int(x) for x in input().split()]
bulbs = []
for i in range(0, a[1]):
	bulbs.append(0)
for i in range(0, a[0]):
	b = [int(x) for x in input().split()]
	for j in range(1, len(b)):
		bulbs[b[j] - 1] = 1
if min(bulbs) == 0:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split(' '))
a = set()
for i in range(n):
	b = list(map(int, input().split(' ')))
	for k in range(1, len(b)):
		a.add(b[k])
for j in range(1, m + 1):
	if j not in a:
		print('NO')
		break
else:
	print('YES')


r = lambda i: map(int, input().split()[i:])
(n, m) = r(0)
a = []
for _ in [0] * n:
	a += r(1)
print('YNEOS'[len(set(a)) != m::2])


(n, m) = map(int, input().split())
z = []
for i in range(n):
	l = list(map(int, input().split()))
	z.append(l[1:])
cnt = []
for i in z:
	cnt += i
if len(set(cnt)) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
res = ''
for x in range(n):
	(no_of_bulb, *bno) = map(int, input().split())
	l.extend(bno)
if len(set(l)) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
yy = []
for i in range(n):
	x = list(map(int, input().split()))
	x = x[1:]
	yy.append(x)
main = []
for i in yy:
	for j in i:
		main.append(j)
main = set(main)
gg = {0}
for i in range(1, m + 1):
	gg.add(i)
gg.remove(0)
if gg == main:
	print('YES')
else:
	print('NO')


b = [0 for i in range(107)]
(n, m) = map(int, input().split())
for _ in range(n):
	(cnt, *bulbs) = map(int, input().split())
	for bulb in bulbs:
		b[bulb] = 1
print(['NO', 'YES'][sum(b[1:m + 1]) == m])


(n, m) = map(int, input().split())
mass = []
for i in range(n):
	tmp_list = list(map(int, input().split()))
	mass += tmp_list[1:]
flag = True
for i in range(1, m + 1):
	if i not in mass:
		flag = False
print('YES') if flag else print('NO')


(n, m) = map(int, input().split())
g = []
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(1, l[0] + 1):
		g.append(l[j])
r = set(g)
if len(r) == m:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	l = [False] * (m + 1)
	for _ in range(n):
		for i in map(int, input().split()[1:]):
			l[i] = True
	print(('NO', 'YES')[all(l[1:])])
main()


(n, m) = [int(x) for x in input().split()]
a = []
k = []
for i in range(n):
	t = [int(g) for g in input().split()]
	for l in range(1, len(t)):
		a.append(t[l])
c = set(a)
for w in range(m):
	k.append(w + 1)
p = set(k)
if c == p:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l2 = []
while n:
	l = list(map(int, input().split()))
	l1 = l[1:]
	l2.append(l1)
	n = n - 1
output = []

def reemovNestings(l2):
	for i in l2:
		if type(i) == list:
			reemovNestings(i)
		else:
			output.append(i)
reemovNestings(l2)
s = set(output)
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, k) = (int(v) for v in input().split())
s = set()
for i in range(n):
	x = [int(u) for u in input().split()]
	x.remove(x[0])
	x = set(x)
	s = s.union(x)
if len(s) == k:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	bon = list(map(int, input().split()))
	for i in range(bon[0]):
		l.append(bon[i + 1])
s = set(l)
if len(s) == m:
	print('YES')
else:
	print('NO')


x = [int(i) for i in input().split(' ')]
m = [i + 1 for i in range(x[1])]
for i in range(x[0]):
	line = [int(i) for i in input().split(' ')]
	h = line[0]
	line = line[1:]
	for j in line:
		if j in m:
			m.remove(j)
print('NO') if m else print('YES')


(m, n) = map(int, input().split())
k = []
for i in range(m):
	l = list(map(int, input().split()))
	k.extend(l[1:])
if len(set(k)) == n:
	print('YES')
else:
	print('NO')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
from collections import deque
BUFSIZE = 8192
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 main():
	(n, m) = map(int, input().split())
	s = set()
	for i in range(n):
		x = list(map(int, input().split()))
		for j in range(1, len(x)):
			s.add(x[j])
	if len(s) < m:
		print('NO')
	else:
		print('YES')
main()


from collections import defaultdict
(n, m) = list(map(int, input().split()))
d = defaultdict(int)
for _ in range(n):
	b = list(map(int, input().split()))
	for i in b[1:]:
		d[i] = 1
ans = 'YES'
for c in range(1, m + 1):
	if d[c] == 0:
		ans = 'NO'
		break
print(ans)


(n, m) = map(int, input().split(' '))
bulbs_condition = [0] * m
for i in range(n):
	bulbes_which_will_be_on = list(map(int, input().split(' ')))
	del bulbes_which_will_be_on[0]
	for j in bulbes_which_will_be_on:
		bulbs_condition[j - 1] = 1
if 0 in bulbs_condition:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split()))
found_ints = set()
for i in range(n):
	one_line = list(map(int, input().split()))[1:]
	for i in one_line:
		found_ints.add(i)
	if len(found_ints) == m:
		print('YES')
		exit()
print('NO')


(n, m) = list(map(int, input().split()))
s = set()
for i in range(n):
	(x, *l) = list(map(int, input().split()))
	for y in l:
		s.add(y)
if len(s) == m:
	print('YES')
else:
	print('NO')


(m, n) = [int(x) for x in input().split()]
s = set()
for i in range(m):
	L = [int(x) for x in input().split()]
	for i in range(1, len(L)):
		s.add(L[i])
if len(s) == n:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbs = set(range(1, m + 1))
for _ in range(n):
	(count, *numbers) = map(int, input().split())
	for number in numbers:
		bulbs -= {number}
if len(bulbs) > 0:
	print('NO')
else:
	print('YES')


(a, b) = map(int, input().split())
s = set([0])
for i in range(a):
	l = list(map(int, input().split()))
	s = set(list(s) + l[1:])
print(['NO', 'YES'][len(s) - 1 == b])


import sys
(s, l) = map(int, input().split())
alllights = set([])
for i in range(s):
	bulbs = [int(j) for j in input().split()]
	bulbs.pop(0)
	alllights.update(bulbs)
if len(alllights) == l:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
connected = [False for _ in range(m)]
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		connected[a[j] - 1] = True
allconnected = True
for j in range(m):
	if connected[j] == False:
		allconnected = False
if allconnected == True:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ans = set()
for i in range(n):
	inp = list(map(int, input().split()))
	for j in range(1, inp[0] + 1):
		if inp[j] in ans:
			continue
		else:
			ans.add(inp[j])
if len(ans) == m:
	print('YES')
else:
	print('NO')


string = input()
numbers = string.split(' ')
a = int(numbers[0])
b = int(numbers[1])
bulbs = []
for x in range(a):
	string = input()
	numbers = string.split(' ')
	n = int(numbers[0])
	for y in range(1, n + 1):
		bulbs.append(int(numbers[y]))
results = 'YES'
for x in range(1, b + 1):
	if not x in bulbs:
		results = 'NO'
		break
print(results)


(n, m) = map(int, input().split())
a = [0] * m
for i in range(n):
	(x, *y) = map(int, input().split())
	for j in y:
		a[j - 1] = 1
print('NO' if 0 in a else 'YES')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	k = [int(x) for x in input().split()]
	for j in range(k[0]):
		l.append(k[j + 1])
print('YES' if set(l) == set(range(1, m + 1)) else 'NO')


(n, m) = [int(x) for x in input().split()]
a = []
for i in range(n):
	b = [int(x) for x in input().split()]
	b.pop(0)
	a = a + b
c = {x for x in range(1, m + 1)}
if set(a) == c:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbs = [None] * m
for i in range(n):
	array = list(map(int, input().split()))
	for j in range(1, array[0] + 1):
		bulbs[array[j] - 1] = 1
result = True
for i in range(m):
	if bulbs[i] is None:
		result = False
		break
if result:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
turn_on = set([])
for i in range(n):
	btns = list(map(int, input().split()))
	for b in btns[1:]:
		turn_on.add(b)
if len(turn_on) == m:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
l = []
for i in range(a):
	s = list(map(int, input().split()))
	s.remove(s[0])
	for i in s:
		l.append(i)
for i in range(1, b + 1):
	if i not in l:
		print('No')
		break
else:
	print('Yes')


(n, m) = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(n)]
T = []
for i in range(n):
	T += L[i][1:]
ok = 1
for i in range(m):
	if T.count(i + 1) == 0:
		ok = 0
		print('NO')
		break
if ok:
	print('YES')


import sys
(n, m) = map(int, input().split())
ans = set()
for i in range(n):
	ans = ans | set(list(map(int, input().split()))[1:])
if len(ans) == m:
	print('YES')
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
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 LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

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

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

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

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = [LI() for _ in range(n)]
	s = set()
	for c in a:
		s |= set(c[1:])
	if len(s) == m:
		return 'YES'
	return 'NO'
print(main())


(bt, bu) = map(int, input().split())
b = []
for i in range(bt):
	a = list(map(int, input().split()))
	b += a[1:]
b = set(b)
if len(b) == bu:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
count = [0] * m
for i in range(n):
	(_, *z) = map(int, input().split())
	for ch in z:
		count[ch - 1] += 1
print('YES' if all((ch > 0 for ch in count)) else 'NO')


(a, b) = map(int, input().split())
x = set()
for i in range(a):
	c = list(map(int, input().split()))
	c.remove(c[0])
	x.update(c)
if len(x) == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
fli = []
for _ in range(n):
	li = list(map(int, input().split()))
	li.remove(li[0])
	fli.extend(li)
if len(set(fli)) == m and max(set(fli)) == m:
	print('YES')
else:
	print('NO')


n = list(map(int, input().split()))
a = set([item for item in range(1, n[1] + 1)])
for i in range(n[0]):
	a = a - set(list(map(int, input().split()))[1:])
print('YES' if len(a) == 0 else 'NO')


l = list(map(int, input().split(' ')))
button = l[0]
bulb = l[1]
a = [0] * bulb
for i in range(0, button):
	b = list(map(int, input().split(' ')))
	c = b[1:b[0] + 1]
	for j in c:
		a[j - 1] = a[j - 1] + 1
for i in a:
	k = 1
	if i == 0:
		k = 0
		print('NO')
		break
if k != 0:
	print('YES')


(n, m) = [int(x) for x in input().split()]
a = []
for i in range(n):
	b = [int(x) for x in input().split()]
	a = a + b[1:]
a = set(a)
print('YES' if len(a) == m else 'NO')


(n, m) = map(int, input().split())
inp = list(map(int, input().split()))
inp.pop(0)
z = set(inp)
for _ in range(1, n):
	inp = list(map(int, input().split()))
	inp.pop(0)
	z |= set(inp)
flag = 0
for i in range(1, m + 1):
	if i in z:
		pass
	else:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')


(n, m) = map(int, input().split())
k = [i for i in range(1, m + 1)]
y = []
for i in range(n):
	x = list(map(int, input().split()))
	x.pop(0)
	for j in range(len(x)):
		y.append(x[j])
y = set(y)
y = list(y)
if y == k:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
flags = [0 for i in range(m)]
for i in range(n):
	bulb_list = list(map(int, input().split()))
	for bulb in bulb_list[1:]:
		flags[bulb - 1] = 1
if sum(flags) == m:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = [0] * b
for i in range(a):
	n = [int(s) for s in input().split()]
	for j in range(1, len(n)):
		c[n[j] - 1] = 1
if 0 in c:
	print('NO')
else:
	print('YES')


from collections import *
from math import *
from itertools import *
import os
import sys
from io import BytesIO, IOBase

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

def PRINT(check: bool, first: str, second: str):
	print(first if check else second)
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 formula(n: int) -> int:
	return n * (n - 1) // 2

def main():
	(n, m) = splint()
	seen = set()
	for _ in range(n):
		ar = set(list(splint())[1:])
		seen.update(ar)
	PRINT(len(seen) == m, 'YES', 'NO')
main()


(n, m) = map(int, input().split())
l1 = []
for i in range(n):
	x = input().split()
	for t in x[1:]:
		if t not in l1:
			l1.append(t)
if len(l1) == m:
	print('YES')
else:
	print('NO')


import re, sys, math, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
RI = lambda : list(map(int, input().split()))
RS = lambda : input().rstrip().split()
(n, m) = RI()
f = [0] * m
for i in range(n):
	inp = RI()[1:]
	for j in inp:
		f[j - 1] = 1
print(['NO', 'YES'][all((f[i] for i in range(m)))])


(m, n) = map(int, input().split())
a = [False] * (n + 1)
a[0] = True
for i in range(m):
	temp = list(map(int, input().split()))
	for kk in temp[1:]:
		a[kk] = True
ans = True
for nn in a:
	ans = nn and ans
if ans:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = []
for i in range(a):
	d = list(map(int, input().split()))
	for i in d[1:]:
		c.append(i)
e = list(set(c))
if len(e) == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
use = [0] * 1000
for i in range(0, n):
	a = list(map(int, input().split()))
	for j in range(1, a[0] + 1):
		use[a[j]] = 1
flag = 1
for i in range(1, m + 1):
	if use[i] == 0:
		flag = 0
if flag == 1:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
s = set()
for x in range(n):
	a = input().split()
	for y in a[1:]:
		s.add(int(y))
print('YES' if len(s) == m else 'NO')


(a, b) = [int(x) for x in input().split()]
l = []
s = []
p = []
for i in range(a):
	t = [int(x) for x in input().split()]
	del t[0]
	l += t
s = list(set(l))
print()
for j in range(1, b + 1):
	p.append(j)
if s != p:
	print('NO')
else:
	print('YES')


def solve(arr):
	for i in arr:
		if i == 0:
			return 'NO'
	return 'YES'
(n, m) = map(int, input().split())
li = [0] * m
for i in range(n):
	arr = list(map(int, input().split()))
	arr.pop(0)
	for j in arr:
		li[j - 1] = 1
print(solve(li))


(n, m) = map(int, input().split())
flags = [True] * m
for _ in range(n):
	for i in list(map(int, input().split()))[1:]:
		flags[i - 1] = False
print(['YES', 'NO'][any(flags)])


(a, b) = map(int, input().split())
list = []
for i in range(a):
	d = input().split()
	for j in range(int(d[0])):
		list.append(d[j + 1])
if len(set(list)) == b:
	print('YES')
else:
	print('NO')


def read():
	return list(map(int, input().split()))
(n, m) = read()
s = []
for _ in range(n):
	s.extend(read()[1:])
print('YES' if len(set(s)) == m else 'NO')


(n, m) = map(int, input().split())
bulbs_on = set()
for _ in range(n):
	b = list(map(int, input().split()))
	for x in b[1:]:
		bulbs_on.add(x)
tmp_st = {i for i in range(1, m + 1)}
if bulbs_on == tmp_st:
	print('YES\n')
else:
	print('NO\n')


(n, m) = map(int, input().split())
state = [False] * m
count = 0
for i in range(n):
	for lamp in tuple(map(int, input().split()))[1:]:
		if not state[lamp - 1]:
			state[lamp - 1] = True
			count += 1
print('YES' if count == m else 'NO')


(n, d) = map(int, input().split())
l = []
for i in range(1, d + 1):
	l.append(i)
a = []
for i in range(n):
	b = list(map(int, input().split()))
	a = a + b[1:]
a = set(a)
a = list(a)
c = 0
for i in range(len(l)):
	if l[i] not in a:
		c = 1
		break
if c == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	x = list(map(int, input().split()))
	x.remove(x[0])
	for j in x:
		l.append(j)
s = set(l)
if m == len(s):
	print('YES')
else:
	print('NO')


import math
x = list(map(int, input().split()))
b = []
s = []
for i in range(0, x[0]):
	s.append(list(map(int, input().split())))
for j in range(0, x[1]):
	b.append(0)
for i in range(0, x[0]):
	for j in range(1, len(s[i])):
		b[s[i][j] - 1] = 1
for i in range(0, len(b)):
	if b[i] == 0:
		print('NO')
		exit()
print('YES')


def solve():
	(n, m) = [int(s) for s in input().split()]
	l = set()
	for i in range(n):
		(x, *y) = [int(s) for s in input().split()]
		l.update(y)
	if len(l) == m:
		print('YES')
	else:
		print('NO')
solve()


b = []
(n, m) = map(int, input().split())
for i in range(n):
	a = [int(i) for i in input().split()]
	for i in range(1, len(a)):
		if a[i] not in b:
			b.append(a[i])
if len(b) == m:
	print('YES')
else:
	print('NO')


def poss():
	(n, m) = map(int, input().split())
	a = [0] * m
	am = 0
	for i in range(n):
		b = list(map(int, input().split()))
		for i in range(1, b[0] + 1):
			if a[b[i] - 1] == 0:
				a[b[i] - 1] = 1
				am += 1
				if am == m:
					return 'YES'
	return 'NO'
print(poss())


(n, m) = map(int, input().split())
lst = [0] * (m + 1)
for i in range(n):
	lstn = list(map(int, input().split()))[1:]
	for j in lstn:
		lst[j] = 1
count = lst.count(1)
if count == m:
	print('YES')
else:
	print('NO')


(n, m) = str(input()).split()
n = int(n)
m = int(m)
line = [0] * m
for i in range(n):
	temp_line = str(input()).split()
	if len(temp_line) > 1:
		for it in temp_line[1:]:
			line[int(it) - 1] = 1
if 0 in line:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
l = []
res = ''
for x in range(n):
	(no_of_bulb, *bno) = map(int, input().split())
	l.extend(bno)
for i in range(1, m + 1):
	if l.count(i) > 0:
		res = 'YES'
	else:
		res = 'NO'
		break
print(res)


(n, m) = map(int, input().split())
b = 0
l = []
for i in range(n):
	a = list(map(int, input().split()))
	for x in range(1, a[0] + 1):
		l.append(a[x])
print(['NO', 'YES'][len(set(l)) == m])


[n, m] = [int(x) for x in input().split()]
L = set()
for i in range(n):
	I = [int(x) for x in input().split()]
	I.remove(I[0])
	L = L.union(set(I))
print('YES' if L == {i + 1 for i in range(m)} else 'NO')


(n, m) = map(int, input().split())
used = [False] * m
for i in range(n):
	(x, *ys) = map(int, input().split())
	for y in ys:
		used[y - 1] = True
print(['NO', 'YES'][all(used)])


(n, m) = map(int, input().split())
s = []
for i in range(n):
	p = list(map(int, input().split()))
	for i in p[1:]:
		s.append(i)
if len(set(s)) == m:
	print('YES')
else:
	print('NO')


(n, b) = map(int, input().split())
l = [i for i in range(1, b + 1)]
for i in range(n):
	c = list(map(int, input().split()))
	for j in range(len(c) - 1):
		if c[j + 1] in l:
			l.remove(c[j + 1])
if len(l) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulb_set = set()
for i in range(n):
	x = [int(j) for j in input().split()]
	del x[0]
	bulb_set.update(x)
print(['NO', 'YES'][len(bulb_set) == m])


(n, m) = map(int, input().split())
lii = [0] * (m + 1)
for _ in range(n):
	li = list(map(int, input().split()))
	for i in range(1, len(li)):
		lii[li[i]] = 1
for i in range(1, m + 1):
	if lii[i] == 0:
		print('NO')
		exit()
print('YES')


li = [int(n) for n in input().split()]
num = []
c = 1
while li[0] > 0:
	l = [int(n) for n in input().split()]
	num.extend(l[1:])
	li[0] -= 1
for i in range(1, li[1] + 1):
	if i not in num:
		c = 0
		break
if c == 0:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
on = [False for _ in range(m + 1)]
for _ in range(n):
	for x in list(map(int, input().split()))[1:]:
		on[x] = True
for i in range(1, m + 1):
	if not on[i]:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
arr = []
b = [i for i in range(1, m + 1)]
for i in range(n):
	a = list(map(int, input().split()))
	a = a[1:]
	arr.extend(list(set(a)))
arr = list(set(arr))
if arr == b:
	print('YES')
else:
	print('NO')


readInts = lambda : list(map(int, input().split()))
(n, m) = readInts()
s = set()
for i in range(n):
	s |= set(readInts()[1:])
print('YES' if len(s) == m else 'NO')


(n, m) = [int(i) for i in input().split()]
ar = m * [False]
for _ in range(n):
	br = [int(i) for i in input().split()]
	for j in br[1:]:
		ar[j - 1] = True
if False in ar:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
dic = [0] * m
for _ in range(n):
	tmp = list(map(int, input().split()))
	for i in range(1, len(tmp)):
		dic[tmp[i] - 1] = 1
if 0 in dic:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
arr = [0 for i in range(m)]
for i in range(n):
	line = stdin.readline().split()
	del line[0]
	for i in line:
		arr[int(i) - 1] = 1
ans = True
for i in arr:
	if i == 0:
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


list = []
(n, m) = input().split(' ')
n = int(n)
for i in range(0, n):
	x = input().split(' ')
	x.pop(0)
	for xi in x:
		if int(xi) not in list:
			list.append(int(xi))
found = False
m = int(m)
for i in range(0, m):
	if int(i) + 1 not in list:
		print('NO')
		found = True
		break
if not found:
	print('YES')


(n, m) = [int(i) for i in input().split()]
a = [0] * m
for i in range(n):
	b = [int(i) for i in input().split()]
	for j in range(1, len(b)):
		a[b[j] - 1] = 1
if sum(a) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	l = list(map(int, input().split()))
	l.remove(l[0])
	s.update(set(l))
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
lights = [False] * m
for _ in range(n):
	(__, *ls) = map(int, input().split())
	for i in ls:
		lights[i - 1] = True
print('NYOE S'[all(lights)::2])


(n, m) = map(int, input().split())
numlist = []
i = 0
while i < n:
	lis = list(input().split())
	numlist += lis[1:]
	i += 1
total = len(numlist)
j = 0
for j in range(total):
	numlist[j] = int(numlist[j])
	j += 1
numlist = set(numlist)
t = int(1)
while t <= m:
	if int(t) not in numlist:
		print('NO')
		break
	else:
		t += 1
if t > m:
	print('YES')


(n, m) = [int(x) for x in input().split()]
a = []
count = 0
for i in range(n):
	k = [int(y) for y in input().split()]
	for elem in k:
		a.append(elem)
	a.remove(k[0])
for j in range(1, m + 1):
	if j not in a:
		count += 1
if count > 0:
	print('NO')
else:
	print('YES')


def main():
	(n, m) = map(int, input().split())
	lights = []
	for _ in range(n):
		lights += list(map(int, input().split()))[1:]
	count_light = set(lights)
	if 0 in count_light and len(count_light) - 1 == m:
		print('YES')
	elif 0 not in count_light and len(count_light) == m:
		print('YES')
	else:
		print('NO')
main()


(n, m) = input().split()
lamps = []
for _ in range(int(n)):
	lamps.extend(input().split()[1:])
print(('NO', 'YES')[len(set(lamps)) == int(m)])


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, M) = map(int, input().split())
on = [0] * (M + 1)
for i in range(N):
	b = [int(x) for x in input().split()]
	for v in b[1:]:
		on[v] = 1
if sum(on) == M:
	print('YES')
else:
	print('NO')


(a, b) = [int(x) for x in input().split()]
s = set()
for y in range(a):
	k = input().split()
	k.pop(0)
	s.update(k)
	k = []
if len(s) == b:
	print('YES')
else:
	print('NO')


l = [0] * 1000
(n, m) = map(int, input().split())
for _ in range(n):
	for x in map(int, input().split()[1:]):
		l[x] += 1
		if l[x] == 1:
			m -= 1
print('NO' if m else 'YES')


(n, m) = [int(x) for x in input().split()]
l = [1 for x in range(m)]
for i in range(n):
	s = [int(x) for x in input().split()]
	s = s[1:]
	for j in s:
		l[j - 1] = 0
if sum(l) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l1 = [int(i) for i in input().split()]
	for i in range(1, l1[0] + 1):
		l.append(l1[i])
l = list(set(l))
l2 = [int(i) for i in range(1, m + 1)]
print(['NO', 'YES'][l2 == l])


(n, m) = map(int, input().split())
lm = [i for i in range(1, m + 1)]
for i in range(n):
	l = list(map(int, input().split()))[1:]
	for u in l:
		if u in lm:
			lm.pop(lm.index(u))
if len(lm) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbs = []
for i in range(n):
	arr = list(map(int, input().split()))
	arr.pop(0)
	for j in arr:
		bulbs.append(j)
if len(list(dict.fromkeys(bulbs))) == m:
	print('YES')
else:
	print('NO')


from itertools import combinations
(n, m) = map(int, input().split())
lamps = [0] * (m + 1)
for i in range(n):
	for j in list(map(int, input().split()))[1:]:
		lamps[j] += 1
if lamps.count(0) == 1:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = set()
for i in range(a):
	c.update(input().split()[1:])
print(['NO', 'YES'][len(c) == b])


(n, m) = map(int, input().split())
v = m * [0]
for i in range(n):
	a = list(map(int, input().split()))
	a.pop(0)
	for j in a:
		v[j - 1] = 1
if v == m * [1]:
	print('YES')
else:
	print('NO')


(a, b) = list(map(int, input().split()))
bulb = [int(x) for x in range(1, b + 1)]
for i in range(a):
	bulblist = [int(x) for x in input().split()]
	for j in bulblist[1:]:
		if bulb.count(j) > 0:
			bulb.remove(j)
	if not bulb:
		break
print(['YES', 'NO'][bulb != []])


(n, m) = map(int, input().split())
c = 0
s = []
for i in range(n):
	(z, *a) = list(map(int, input().split()))
	for j in a:
		if j not in s:
			s.append(j)
if len(s) == m:
	print('YES')
else:
	print('NO')


temp = [int(x) for x in input().split()]
n = temp[0]
m = temp[1]
checked = [False for x in range(m)]
for i in range(n):
	temp = [int(x) for x in input().split()]
	temp = temp[1:]
	for x in temp:
		checked[x - 1] = True
if checked == [True] * m:
	print('YES')
else:
	print('NO')


(buttons, bulbs) = list(map(int, input().split()))
b = []
for i in range(buttons):
	n = list(map(int, input().split()))
	n.remove(n[0])
	for i in n:
		b.append(i)
if len(set(b)) == bulbs:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ls = []
x = []
no = []
B = []
for i in range(1, m + 1):
	B.append(i)
while n:
	n -= 1
	ls = list(map(int, input().split()))
	x.append(ls[0])
	for i in ls[1:]:
		no.append(i)
no = set(no)
no = list(no)
if no == B:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
bulbs = []
for i in range(n):
	bulb = [int(x) for x in input().split()]
	for j in range(1, len(bulb)):
		bulbs.append(bulb[j])
k = set(bulbs)
if len(k) == m:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
l = []
for i in range(a):
	x = [int(x) for x in input().split()]
	for j in range(1, len(x)):
		if x[j] not in l:
			l.append(x[j])
print('YES' if len(l) == b else 'NO')


__author__ = 'suvasish'
(n, m) = map(int, input().split())
m_lst = [0] * m
for l in range(0, n):
	inp = list(map(int, input().split()))
	for b in range(1, len(inp)):
		if m_lst[inp[b] - 1] == 0:
			m_lst[inp[b] - 1] = 1
print('NO') if m_lst.count(0) >= 1 else print('YES')


(n, m) = map(int, input().split())
al = set()
for i in range(n):
	temp = list(map(int, input().split(' ')))
	for i in temp[1:]:
		al.add(i)
if len(al) != m:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
c = []
z = []
for i in range(1, m + 1):
	c.append(i)
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		z.append(a[j])
z = list(set(z))
z.sort()
if z == c:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ans = []
for i in range(n):
	lis = list(map(int, input().split()))
	ans.extend(lis[1:])
s = set(ans)
if len(s) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ls = [False for i in range(m)]
for i in range(n):
	(x, *ys) = list(map(int, input().split()))
	for y in ys:
		ls[y - 1] = True
for l in ls:
	if not l:
		print('NO')
		break
else:
	print('YES')


(n, m) = [int(i) for i in input().split()]
d = set()
for i in range(n):
	(_, *a) = [int(i) for i in input().split()]
	d |= set(a)
if len(d) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for _ in range(n):
	bulbs = list(map(int, input().split()))
	bulbs = set(bulbs[1:])
	for i in bulbs:
		if i not in a:
			a.append(i)
if len(a) == m:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
s = set()
for a in range(n):
	s |= set(input().split()[1:])
for b in range(m):
	if str(b + 1) in s:
		continue
	else:
		print('NO')
		quit()
print('YES')


(n, m) = map(int, input().split())
x = set()
for _ in range(n):
	x.update(input().split()[1:])
if len(x) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
k = []
for i in range(n):
	d = input().split()
	k += d[1:]
l = 0
for j in range(1, m + 1):
	if str(j) in k:
		l += 1
if l == m:
	print('YES')
else:
	print('NO')


def solve(a, n):
	for i in range(1, n + 1):
		if i in a:
			continue
		else:
			return 'NO'
	return 'YES'
(button, bulb) = map(int, input().split())
a = []
for i in range(button):
	x = []
	x = list(map(int, input().strip().split()))
	x.pop(0)
	a = a + x
print(solve(a, bulb))


s1 = input()
l1 = s1.split()
n = int(l1[0])
m = int(l1[1])
i = 0
l4 = list()
while i < n:
	s2 = input()
	l2 = s2.split()
	l3 = list((int(l) for l in l2))
	l3.pop(0)
	for k in l3:
		l4.append(k)
	i += 1
else:
	for i in range(1, m + 1):
		if i not in l4:
			print('NO')
			break
	else:
		print('YES')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(1, len(l)):
		s.add(l[j])
print(['NO', 'YES'][len(s) == m])


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

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

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	while p * p <= n:
		if n % p == 0:
			return n // p
		p = p + 1
	return False

def expo(x, n):
	result = 1
	while n > 1:
		if n & 1:
			n = n - 1
			result = result * x
		else:
			n = n // 2
			x = x * x
	return result * x

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

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

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
Arr = [0] * (m + 1)
for i in range(n):
	myArr = get_array()
	for i in range(1, myArr[0] + 1):
		Arr[myArr[i]] = 1
flag = 0
for i in range(1, m + 1):
	if Arr[i] != 1:
		flag = 1
		break
if flag == 0:
	print('YES')
else:
	print('NO')


x = input().split()
y = []
p = []
flag = 1
for i in range(int(x[0])):
	p = input().split()
	p.pop(0)
	y = y + p
y = list(dict.fromkeys(y))
for i in range(int(x[1])):
	if str(i + 1) in y:
		continue
	else:
		print('NO')
		flag = 0
		break
if flag == 1:
	print('YES')


(n, m) = map(int, input().split())
myBulb = []
for i in range(n):
	arr = list(map(int, input().split()))
	myBulb += arr[1:]
checkConn = True
for k in range(1, m + 1):
	if k not in myBulb:
		print('NO')
		checkConn = False
		break
if checkConn == True:
	print('YES')


(n, m) = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
cond = True
for i in range(1, m + 1):
	d[i] = 0
for _ in range(n):
	arr = list(map(int, input().split()))
	arr.pop(0)
	for num in arr:
		d[num] += 1
for val in d.values():
	if val == 0:
		print('NO')
		cond = False
		break
if cond:
	print('YES')


(n, m) = [int(i) for i in input().split()]
l1 = []
while n:
	n -= 1
	l = [int(i) for i in input().split()]
	l1.extend(l[1:])
if len(set(l1)) == m:
	print('YES')
else:
	print('NO')


(m, n) = input().split()
(m, n) = (int(m), int(n))
lst = []
lst1 = []
for item in range(m):
	lst = [int(x) for x in input().split()]
	lst.pop(0)
	for i in lst:
		lst1.append(i)
for r in range(1, n + 1):
	if r not in lst1:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
turn = [False] * (m + 1)
count = 0
for i in range(n):
	bulbs = list(map(int, input().split()))
	for x in bulbs[1:]:
		if not turn[x]:
			count += 1
			turn[x] = True
print('YES' if count == m else 'NO')


(n, m) = map(int, input().split())
ans = []
for i in range(n):
	t = []
	t += map(int, input().split())
	for j in range(1, len(t)):
		if t[j] not in ans:
			ans.append(t[j])
if len(ans) == m:
	print('YES')
else:
	print('NO')


y = input().split()
m = int(y[0])
n = int(y[1])
S = [0 for i in range(n + 1)]
M = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
	for j in range(1, M[i][0] + 1):
		S[M[i][j]] = S[M[i][j]] + 1
k = S.count(0)
if k > 1:
	print('NO')
else:
	print('YES')


(m, n) = map(int, input().split())
used = [False] * n
k = 0
for i in range(m):
	arr = list(map(int, input().split()))[1:]
	for t in arr:
		if not used[t - 1]:
			used[t - 1] = True
			k += 1
if k == n:
	print('YES')
else:
	print('NO')


(buttons, bulbs) = map(int, input().split())
state = []
for i in range(buttons):
	t = input().split()
	for j in t[1:]:
		state.append(int(j))
uniq = list(set(state))
if len(uniq) == bulbs:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
t = [True] * m
for i in range(n):
	a = list(map(int, input().split()))
	for j in a[1:]:
		t[j - 1] = False
for i in t:
	if i:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
Union = set()
for i in range(n):
	L = input().split()
	t = int(L[0])
	s = {int(L[i]) for i in range(1, t + 1)}
	Union = Union | s
if Union == {i + 1 for i in range(m)}:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
list1 = []
listk = []
for i in range(m):
	list1.append(i + 1)
for i in range(n):
	listj = list(map(int, input().split()))
	listj.pop(0)
	for j in listj:
		listk.append(j)
set1 = set(list1)
set2 = set(listk)
if set1 == set2:
	print('YES')
else:
	print('NO')


s1 = input()
n = int(s1.split()[0])
m = int(s1.split()[1])
d = {}
for i in range(0, n):
	s2 = input()
	xi = int(s2.split()[0])
	for j in range(1, xi + 1):
		tmp = int(s2.split()[j])
		d[str(tmp)] = 1
flag = 0
for i in range(1, m + 1):
	if str(i) not in d:
		flag = 1
if flag == 0:
	print('YES')
else:
	print('NO')


data = [int(x) for x in input().split()]
y = []
for i in range(data[0]):
	y += [int(z) for z in input().split()][1:]
if all([n in y for n in range(1, data[1] + 1)]):
	print('YES')
else:
	print('NO')


def check_bulbs(m, n, buttons):
	checker = [0] * m
	for i in range(n):
		bulbs = buttons[i]
		for x in bulbs:
			if 0 < x <= m:
				checker[x - 1] += 1
	for c in checker:
		if c == 0:
			return 'NO'
	return 'YES'
(n, m) = input().split()
(n, m) = (int(n), int(m))
buttons = [None] * n
for i in range(n):
	current = input().split()
	current = [int(x) for x in current]
	buttons[i] = current[1:]
result = check_bulbs(m, n, buttons)
print(result)


(n, m) = map(int, input().split())
c = 1
d = [0 for i in range(200)]
for i in range(n):
	a = [int(j) for j in input().split()]
	for j in a[1:]:
		d[j] = 1
for i in d[1:m + 1]:
	if not i:
		c = 0
		print('NO')
		break
if c:
	print('YES')


def bulbs(n, m, seq):
	yList = []
	for l in seq:
		s = list(l)
		x = s[0]
		yList.append(s[1:x + 1])
	ySet = set()
	for item in yList:
		for i in item:
			ySet.add(i)
	if len(ySet) == m:
		return 'YES'
	else:
		return 'NO'
(n, m) = [int(x) for x in input().split()]
seq = []
while n > 0:
	seq.append((int(x) for x in input().split()))
	n -= 1
print(bulbs(n, m, seq))


(n, m) = map(int, input().split())
total = []
for i in range(n):
	total += input().split()[-1:0:-1]
print(['NO', 'YES'][len(set(total)) == m])


(a, b) = map(int, input().split())
d = [i for i in range(1, b + 1)]
for k in range(a):
	c = list(map(int, input().split()))
	for i in range(1, len(c)):
		d[c[i] - 1] = 0
if sum(d) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
A = []
for _ in range(n):
	a = list(map(int, input().split()))
	A.extend(a[1:])
if len(set(A)) == m:
	print('YES')
else:
	print('NO')


import sys
(n, m) = [int(i) for i in input().split(' ')]
c = [0 for i in range(m)]
for i in range(n):
	k = [int(i) for i in input().split(' ')]
	for i in range(k[0]):
		c[k[i + 1] - 1] += 1
print('YES' if min(c) else 'NO')


(n, m) = map(int, input().split())
ar = {}
for i in range(m):
	ar[i + 1] = 0
arr = []
for __ in range(n):
	arr.append(list(map(int, input().split())))
for i in range(n):
	for j in range(1, arr[i][0] + 1):
		ar[arr[i][j]] = 1
if 0 in ar.values():
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
a = set()
for i in range(n):
	k = input().split()
	for x in k[1:]:
		a.add(int(x))
b = set(range(1, m + 1))
if a == b:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
k = [0] * m
for i in range(n):
	l = list(map(int, input().split()))
	l = l[1:]
	for _ in l:
		k[_ - 1] = 1
if k.count(1) == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
c = []
for i in range(n):
	a = list(map(int, input().split()))
	del a[0]
	c = c + a
aa = [i + 1 for i in range(m)]
bb = list(set(c))
bb.sort()
if bb == aa:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
flag = [False] * m
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		flag[a[j] - 1] = True
f = False
for i in range(m):
	if flag[i] == False:
		print('NO')
		f = True
		break
if f == False:
	print('YES')


(n, m) = map(int, input().split())
arr = [0] * m
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(1, len(a)):
		arr[a[i] - 1] = 1
if arr.count(1) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for _ in range(n):
	for i in input().split()[1:]:
		s.add(i)
	if len(s) == m:
		print('YES')
		break
else:
	print('NO')


(x, y) = map(int, input().split())
iz = set()
for t in range(x):
	t = list(map(int, input().split()))
	for p in range(1, t[0] + 1):
		iz.add(t[p])
if len(iz) != y:
	print('NO')
else:
	print('YES')


n = set()
(a, b) = map(int, input().split())
[n.update(map(int, input().split()[1:])) for i in ' ' * a]
print('NYOE S'[len(n) == b::2])


(buttons, lamps) = map(int, input().split())
a = []
for i in range(buttons):
	a += map(int, input().split()[1:])
if len(set(a)) == lamps:
	print('YES')
else:
	print('NO')


(N, M) = map(int, input().split())
bulbs = list(range(1, M + 1))
for a in range(0, N):
	bS = list(map(int, input().split()))
	del bS[0]
	for b in bS:
		if b in bulbs:
			bulbs.remove(b)
if bulbs == []:
	print('YES')
else:
	print('NO')


[n, m] = [int(x) for x in input().split()]
bulbs = set()
for i in range(n):
	bulbs.update([int(x) for x in input().split()][1:])
print(['NO', 'YES'][bulbs == set([int(x) for x in range(1, m + 1)])])


(n, m) = map(int, input().split())
a = [0] * m
for i in range(n):
	x = list(map(int, input().split()))
	for i in range(1, x[0] + 1):
		a[x[i] - 1] = 1
if sum(a) == m:
	print('YES')
else:
	print('NO')


reader = lambda : map(int, input().split())
(n, m) = reader()
counters = {}
for i in range(n):
	lights = list(reader())[1:]
	for j in lights:
		counters[j] = counters.get(j, 0) + 1
for j in range(1, m + 1):
	if j not in counters:
		print('NO')
		break
else:
	print('YES')


(num_but, num_lmp) = map(int, input().split(' '))
switched = list('-' * num_lmp)
for i in range(num_but):
	inp = input()
	inp = inp.split(' ')
	inp = inp[1:]
	for lamp in inp:
		switched[int(lamp) - 1] = '+'
for lamp in range(len(switched)):
	if switched[lamp] == '-':
		print('NO')
		break
else:
	print('YES')


(n, m) = tuple(map(int, input().split(' ')))
s = set()
for _ in range(n):
	l = [int(v) for v in input().split(' ')][1:]
	s = s.union(set(l))
if set(range(1, m + 1)) == s:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
res = set.union(*(set(map(int, input().split()[1:])) for _ in range(n)))
print('YES' if len(res) == m else 'NO')


(n, m) = map(int, input().split())
x = [i for i in range(1, m + 1)]
l = []
for i in range(n):
	a = list(map(int, input().split()))
	b = [i for i in a[1:]]
	l += b
l = list(set(l))
l.sort()
if l == x:
	print('YES')
else:
	print('NO')


(n, bulb) = map(int, input().split())
b = []
count = 0
for x in range(n):
	a = list(map(int, input().split()))
	for y in range(int(a[0])):
		b.append(a[y + 1])
if len(set(b)) == bulb:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
x = set()
for _ in range(n):
	inp = list(map(int, input().split()))
	for i in range(1, inp[0] + 1):
		x.add(inp[i])
if len(x) == m:
	print('YES')
else:
	print('NO')


import sys
if False:
	inp = open('A.txt', 'r')
else:
	inp = sys.stdin
(n, m) = map(int, inp.readline().split())
bulbs = []
for i in range(n):
	bulbs += list(map(int, inp.readline().split()))[1:]
bulbs = set(bulbs)
if len(bulbs) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
a = [1] * m
for i in range(n):
	b = [int(x) for x in input().split()]
	for j in range(b[0]):
		a[b[j + 1] - 1] = 0
print(['YES', 'NO'][sum(a) != 0])


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	x = list(map(int, input().split()))[1:]
	for c in x:
		s.add(c)
f = True
for i in range(1, m + 1):
	if i not in s:
		f = False
if f:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	a = [int(x) for x in input().split()]
	a.remove(a[0])
	l += a
l = list(set(l))
if len(l) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a += map(int, input().split())
(t, a[0]) = (0, 0)
for i in range(1, m + 1):
	if i in a:
		t += 1
if t == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(item) for item in input().split()]
u = [0] * (m + 1)
u[0] = 1
for i in range(n):
	l = [int(item) for item in input().split()][1:]
	for k in l:
		u[k] = 1
for i in range(m + 1):
	if u[i] == 0:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().strip().split())
nl = []
c = 0
for i in range(n):
	lst = list(map(int, input().strip().split()))
	nl += lst[1:]
	nl.sort()
for i in range(1, m + 1):
	if i not in nl:
		c = 1
		break
if c == 0:
	print('YES')
else:
	print('NO')


inp1 = list(map(int, input().split()))
s = set()
for x in range(inp1[0]):
	inp2 = input().split()
	del inp2[0]
	s.update(set(inp2))
if len(s) == int(inp1[1]):
	print('YES')
else:
	print('NO')


(num_buttons, num_bulbs) = map(int, input().split())
lit = set()
for i in range(num_buttons):
	data = list(map(int, input().split()))
	for x in data[1:]:
		lit.add(x)
if len(lit) == num_bulbs:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
sett = set()
for i in range(m):
	sett.add(i + 1)
for j in range(n):
	bulbs = input()
	if ' ' in bulbs:
		first_space = bulbs.find(' ')
		howmanyconnected = int(bulbs[0:first_space])
		bulbs = bulbs[first_space + 1:]
		for k in range(howmanyconnected):
			if ' ' in bulbs:
				next_space = bulbs.find(' ')
				what_bulb = int(bulbs[0:next_space])
				if what_bulb in sett:
					sett.remove(what_bulb)
				bulbs = bulbs[next_space + 1:]
			else:
				what_bulb = int(bulbs)
				if what_bulb in sett:
					sett.remove(what_bulb)
if sett == set():
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s_total = []
for i in range(n):
	l = [int(x) for x in input().split()]
	del l[0]
	s_total.extend(l)
s = set(s_total)
x = True
i = 1
while i <= m:
	if i not in s:
		x = False
		break
	i += 1
if x:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
bulbs = [0 for i in range(0, m)]
for i in range(0, n):
	b = [int(x) for x in input().split()]
	for j in range(1, len(b)):
		bulbs[b[j] - 1] = 1
broke = False
for bulb in bulbs:
	if bulb == 0:
		print('NO\n')
		broke = True
		break
if not broke:
	print('YES\n')


(buttons, bulbs) = map(int, input().split())
d = dict()
for i in range(buttons):
	raw = list(map(int, input().split()))
	d[i] = raw[1:]
possibilities = set([i for i in range(1, bulbs + 1)])
for (k, v) in d.items():
	v2 = set(v)
	possibilities.difference_update(v2)
if possibilities:
	print('NO')
else:
	print('YES')


s = str(input()).split()
n = int(s[0])
m = int(s[1])
bulbs = set()
for i in range(n):
	s = str(input()).split()
	mm = []
	for ii in range(1, len(s)):
		mm += [int(s[ii])]
		bulbs.add(int(s[ii]))
if len(bulbs) == m:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
on = set()
for _ in range(n):
	(head, *tail) = input().split()
	on.update(map(int, tail))
for i in range(1, m + 1):
	if i not in on:
		print('NO')
		break
else:
	print('YES')


s = input().split()
k = []
n = 0
for i in range(int(s[0])):
	j = input().split()
	for o in range(1, int(j[0]) + 1):
		k.append(j[o])
for i in range(1, int(s[1]) + 1):
	for m in k:
		if m == str(i):
			n += 1
			break
if n == int(s[1]):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = set()
for i in range(n):
	a = list(map(int, input().split(' ')))
	s = s.union(a[1:])
print('YES' if len(s) == m else 'NO')


class Solution:

	def checkPosible(self, n, S):
		Set = []
		for i in range(n):
			Set += list(map(int, input().split(' ')))[1:]
		if sum(set(Set)) == Sm:
			return 'YES'
		else:
			return 'NO'
(n, m) = list(map(int, input().split(' ')))
Sm = sum([i for i in range(1, m + 1)])
S = Solution()
print(S.checkPosible(n, Sm))


(n, m) = [int(x) for x in input().split()]
used = [False] * m
for i in range(n):
	s = [int(x) for x in input().split()]
	num = s.pop(0)
	for elem in s:
		used[elem - 1] = True
for elem in used:
	if not elem:
		print('NO')
		break
else:
	print('YES')


(n, m) = map(int, input().split())
a = [i for i in range(1, m + 1)]
s = []
for i in range(n):
	b = list(map(int, input().split()))
	del b[0]
	s += b
s = set(s)
if len(s) == m:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
x = 0
l = []
while m:
	m -= 1
	l1 = input().split()
	l1.remove(l1[0])
	l += l1
for i in range(1, n + 1):
	if str(i) not in l:
		x += 1
if x == 0:
	print('YES')
else:
	print('NO')


__author__ = 'MoonBall'
import sys
T = 1

def process():
	(N, M) = list(map(int, input().split()))
	f = [0] * (M + 1)
	for _ in range(N):
		a = list(map(int, input().split()))
		for i in range(a[0]):
			f[a[i + 1]] = 1
	print('YES' if sum(f) == M else 'NO')
for _ in range(T):
	process()


(n, b) = map(int, input().split())
res = [0] * b
for i in range(n):
	ind = list(map(int, input().split()))
	ind.pop(0)
	for j in ind:
		if res[j - 1] == 0:
			res[j - 1] = 1
if res.count(0) >= 1:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
alist = []
sumlist = []
for i in range(n):
	a = list(input().split())
	del a[0]
	sumlist = sumlist + a
	alist.append(a)
if len(set(sumlist)) == m:
	print('YES')
else:
	print('NO')


x = input()
x = x.split()
a = []
c = []
d = []
z = -1
yonax = 0
for k in range(int(x[0])):
	y = input()
	y = y.split()
	if int(y[0]) == 0:
		yonax = yonax + 1
	a.append(y)
if yonax == int(x[0]):
	print('NO')
else:
	for y in range(int(x[0])):
		for b in range(1, int(a[y][0]) + 1):
			c.append(int(a[y][b]))
	numero = len(c)
	c.sort(reverse=True)
	for s in range(numero):
		for z in range(s + 1, numero):
			if c[s] != c[z]:
				a = 1
			else:
				a = 0
				break
		if a == 1:
			d.append(c[s])
	if len(d) == 0:
		d.append(c[len(c) - 1])
	elif c[len(c) - 1] != d[len(d) - 1]:
		d.append(c[len(c) - 1])
	if len(d) == int(x[1]):
		print('YES')
	else:
		print('NO')


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest

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

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
(n, m) = read_int_array()
turned = set()
for i in range(n):
	(xi, *yij) = read_int_array()
	for b in yij:
		turned.add(b)
print('YES' if len(turned) == m else 'NO')


(n, m) = map(int, input().split())
given = set(range(1, m + 1))
maken = set()
for i in range(n):
	for elem in map(int, input().split()[1:]):
		maken.add(elem)
print('YES' if given.issubset(maken) else 'NO')


(n, m) = map(int, input().split())
bulb = {i: 0 for i in range(1, m + 1)}
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(1, len(x)):
		bulb[x[j]] = 1
flag = 1
for i in range(1, m + 1):
	if bulb[i] == 0:
		print('NO')
		flag = 0
		break
if flag:
	print('YES')


(n, m) = map(int, input().split())
l = [0] * m
for i in range(n):
	(x, *y) = map(int, input().split())
	for h in y:
		l[h - 1] = 1
if 0 in l:
	print('NO')
else:
	print('YES')


(n, m) = tuple(map(int, input().split()))
turned = set()
for i in range(n):
	lamps = list(map(int, input().split()))
	for j in range(lamps[0]):
		turned.add(lamps[j + 1])
if len(turned) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
b1 = []
for i in range(n):
	a = input().split()
	for j in a[1:]:
		b1.append(j)
b2 = list(set(b1))
if m == len(b2):
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
lights = [1] * m
for i in range(n):
	a = input()
	if a[0] != '0':
		n = a.find(' ')
		for j in [int(x) for x in a[n + 1:].split()]:
			lights[j - 1] = 0
if sum(lights) == 0:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
L1 = []
for k in range(a):
	L = list(map(int, input().split()))
	for j in range(1, L[0] + 1):
		L1.append(L[j])
L1 = set(L1)
print(['NO', 'YES'][len(L1) == b])


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(n, m) = get_list()
s = set()
for _ in range(n):
	s.update(get_list()[1:])
flag = True
for i in range(1, m + 1):
	if i not in s:
		print('NO')
		flag = False
		break
if flag:
	print('YES')


counts = input().split()
x = []
canOn = []
for i in range(int(counts[0])):
	n = list(map(int, input().split()))
	canOn.append(n[1:])
s = set([item for subList in canOn for item in subList])
if s == set(range(1, int(counts[1]) + 1)):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
lis = [0] * m
for i in range(n):
	templist = list(map(int, input().split()))
	for j in templist[1:]:
		lis[j - 1] += 1
for i in range(m):
	if lis[i] == 0:
		print('NO')
		break
else:
	print('YES')


(n, m) = list(map(int, input().split()))
a = set(range(1, m + 1))
s = set()
for i in range(n):
	x = list(map(int, input().split()))
	for j in x[1:]:
		s.add(j)
if a - s == set():
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
s = {}
for i in range(n):
	x = list(map(int, input().split()))
	for y in x[1:]:
		s[y] = True
print('YES' if all((False if not y in s.keys() else True for y in range(1, m + 1))) else 'NO')


import math, fractions
(n, m) = [int(x) for x in input().split()]
q = []
for _ in range(n):
	t = [int(x) for x in input().split()][1:]
	for x in t:
		q.append(x)
print('YES' if len(set(q)) == m else 'NO')


(n, m) = [int(i) for i in input().split()]
a = []
for i in range(n):
	b = [int(j) for j in input().split()]
	for j in b[1:]:
		if j not in a:
			a.append(j)
c = 0
for i in range(1, m + 1):
	if i in a:
		c += 1
if c == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
L = []
no = True
for i in range(n):
	L += input().split()[1:]
	if len(set(L)) == m:
		no = False
		break
print(['YES', 'NO'][no])


(x, y) = [int(a) for a in input().split()]
a = []
for i in range(x):
	z = [int(a) for a in input().split()]
	z.pop(0)
	for i in z:
		a.append(i)
if len(set(a)) == y:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
se = set([])
for i in range(n):
	L = list(map(int, input().split()))
	L = L[1:]
	for l in L:
		se.add(l)
if len(se) == m:
	print('YES')
else:
	print('NO')


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	(n, m) = read()
	sett = set()
	for _ in range(n):
		sett.update(read()[1:])
	print('YNEOS'[len(sett) != m::2])
solve()


(n, m) = map(int, input().split())
d = {}
for i in range(n):
	ls = list(map(int, input().split()))
	for i in ls[1:]:
		d[i] = 1
cnt = 0
for (k, v) in d.items():
	cnt += 1
if cnt < m:
	print('NO')
else:
	print('YES')


(n, m) = input().split()
(n, m) = [int(n), int(m)]
on = []
for _ in range(n):
	(i, *a) = map(int, input().split(' '))
	on.extend(a)
checker = {i for i in range(1, m + 1)}
if checker == set(on):
	print('YES')
else:
	print('NO')


import math
nm = input().split()
n = int(nm[0])
m = int(nm[1])
lis = [0 for i in range(m + 1)]
for _ in range(n):
	inp = list(map(int, input().split()))
	inp.pop(0)
	for i in inp:
		lis[i] = 1
		prev = i
if sum(lis) == m:
	print('YES')
else:
	print('NO')


l = list(map(int, input().split()))
l1 = []
for _ in range(l[0]):
	l1.append(list(map(int, input().split())))
l3 = []
for i in range(l[0]):
	for j in range(1, len(l1[i])):
		l3.append(l1[i][j])
se = set(l3)
for i in range(1, l[1] + 1):
	if i not in se:
		print('NO')
		exit()
print('YES')


(n, m) = map(int, input().strip().split()[:2])
bulb = list((0 for x in range(m + 1)))
for x in range(n):
	k = list(map(int, input().strip().split()[:m + 1]))
	for y in k[1:]:
		bulb[y] = 1
if all(bulb[1:]) == True:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
possible = set()
for _ in range(n):
	lst = list(map(int, input().split()))
	for element in lst[1:]:
		possible.add(element)
for i in range(1, m + 1):
	if i not in possible:
		exit(print('NO'))
print('YES')


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()]
(nb_buttons, nb_bulbs) = read_ints()
all_bulbs = set()
for _ in range(nb_buttons):
	all_bulbs.update(read_ints()[1:])
print('YES' if len(all_bulbs) == nb_bulbs else 'NO')


(n, m) = input().split()
(n, m) = [int(n), int(m)]
bulb = []
for i in range(n):
	t = [int(x) for x in input().split()]
	for j in range(1, len(t)):
		bulb.append(t[j])
flag = 0
for j in range(m):
	if not j + 1 in bulb:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')


(n, m) = map(int, input().split())
list1 = []
for i in range(n):
	b = map(int, input().split())
	a = next(b)
	for j in range(a):
		list1.append(next(b))
a = set(list1)
x = 0
for i in range(1, m + 1):
	if i not in a:
		x = 1
		break
print(['YES', 'NO'][x])


import sys
(n, m) = sys.stdin.readline().split()
m = int(m)
d = {i: 0 for i in range(m)}
for i in range(int(n)):
	for s in sys.stdin.readline().split()[1:]:
		b = int(s)
		d[b - 1] = 1
for i in range(m):
	if d[i] == 0:
		print('NO')
		exit(0)
print('YES')


import sys
si = True
i = 0
j = 0
n = []
an = []
m = None
for line in sys.stdin:
	l = line.split()
	if len(l) != 0:
		if i == 0:
			m = int(l[1])
			for x in range(m):
				n.append(x + 1)
		else:
			for x in range(int(l[0])):
				if int(l[x + 1]) in n and (not int(l[x + 1]) in an):
					an.append(int(l[x + 1]))
					j += 1
				else:
					si = False
		i += 1
	else:
		break
if len(an) == len(n):
	print('YES')
else:
	print('NO')


f = lambda : map(int, input().split())
(n, r) = f()
l = []
for i in range(n):
	(b, *blb) = f()
	for i in blb:
		if not i in l:
			l.append(i)
print('YNEOS'[len(l) != r::2])


def solve(t_id):
	(n, m) = map(int, input().split())
	d = {}
	for i in range(n):
		a = list(map(int, input().split()))
		for i in range(1, len(a)):
			d[a[i]] = 1
	print('YES' if len(d) == m else 'NO')
t = 1
for t_id in range(1, t + 1):
	solve(t_id)
	t -= 1


(n, m) = [int(x) for x in input().split()]
bulbs = set([])
for i in range(n):
	for j in map(int, input().split()[1:]):
		bulbs.add(j)
if len(bulbs) >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
d = []
e = set()
for i in range(n):
	s = [int(i) for i in input().split()]
	l = s[0]
	d.append(s[1:])
if s[0] == 0:
	print('NO')
else:
	for i in d:
		for j in range(len(i)):
			e.add(i[j])
	e = list(e)
	if len(e) == max(e) and max(e) == m:
		print('YES')
	else:
		print('NO')


import sys

class Bulb:

	def __init__(self, n):
		self.set = set(range(1, n + 1))

	def insert(self, bulbs):
		for n in bulbs:
			if n in self.set:
				self.set.remove(n)

	def get(self):
		if len(self.set) == 0:
			print('YES')
		else:
			print('NO')

def main():
	(button, bulbs) = [int(x) for x in sys.stdin.readline().split()]
	test = Bulb(bulbs)
	for i in range(button):
		arr = [int(x) for x in sys.stdin.readline().split()]
		test.insert(arr[1:])
	test.get()
main()


(n, m) = map(int, input().split())
a = set()
for i in range(n):
	elems = list(map(int, input().split()))
	for elem in elems[1:]:
		a.add(elem)
print('YES' if len(a) == m else 'NO')


(m, n) = map(int, input().split())
l = [False for i in range(0, n)]
for i in range(0, m):
	for j in [int(x) for x in input().split()][1:]:
		if not l[j - 1]:
			l[j - 1] = True
print(['NO', 'YES'][min(l)])


nm = input()
nm = nm.split(' ')
data = [input().split(' ') for i in range(int(nm[0]))]
bulbs = list()
for btn in data:
	btn.pop(0)
	for bulb in btn:
		bulbs.append(int(bulb))
if list(set(bulbs)) == list(range(1, int(nm[1]) + 1)):
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, m) = [int(i) for i in input().split()]
d = defaultdict(int)
for i in range(n):
	u = [int(i) for i in input().split()]
	for j in u[1:]:
		d[j] = 1
check = True
for i in range(1, m + 1):
	if d[i] == 0:
		check = False
		break
if check:
	print('YES')
else:
	print('NO')


(m, n) = [int(x) for x in input().split()]
set0 = set()
set1 = set((str(i + 1) for i in range(n)))
for i in range(m):
	set0 = set0 | set(input().split()[1:])
print(['YES', 'NO'][set0 != set1])


(n, m) = [int(i) for i in input().split()]
blubs = set()
for i in range(n):
	for item in input().split()[1:]:
		blubs.add(item)
print('%s' % ('YES' if len(blubs) == m else 'NO'))


(n, m) = map(int, input().split(' '))
A = []
for i in range(n):
	x = [int(p) for p in input().split(' ')]
	A.extend(x[1:])
if len(set(A)) == m:
	print('YES')
else:
	print('NO')


args = list(map(int, input().split()))
n = args[0]
m = args[1]
bulbs = []
for i in range(n):
	for j in list(map(int, input().split()))[1:]:
		bulbs.append(j)
bulbs = list(set(bulbs))
if len(bulbs) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
tmp = set([i for i in range(1, m + 1)])
for i in range(n):
	tmp -= set([int(x) for x in input().split()][1:])
if tmp == set():
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
tmpList = [item for item in range(1, m + 1)]
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(1, len(x)):
		if x[j] in tmpList:
			tmpList.remove(x[j])
print('YES' if len(tmpList) == 0 else 'NO')


a = input().split()
(n, m) = (int(a[0]), int(a[1]))
b = set()
for i in range(1, m + 1):
	b.add(str(i))
p = set()
for i in range(1, n + 1):
	a = input().split()
	a.pop(0)
	p = p.union(set(a))
if p == b:
	print('YES')
else:
	print('NO')


def int_lst_input():
	return [int(val) for val in input().split(' ')]

def int_input():
	return int(input())

def print_lst(lst):
	print(' '.join([str(val) for val in lst]))

def solve():
	(n, m) = int_lst_input()
	state = [False for _ in range(m)]
	for _ in range(n):
		(_, *y) = int_lst_input()
		for val in y:
			state[val - 1] = True
	print('YES' if all(state) else 'NO')
solve()


(n, m) = map(int, input().split())
bulbOn = [False] * m
for i in range(n):
	turnedOn = list(map(int, input().split()))
	if turnedOn[0] != 0:
		for j in turnedOn[1:]:
			bulbOn[j - 1] = True
print('YES' if bulbOn == [True] * m else 'NO')


(n, m) = map(int, input().split())
x = []
for i in range(n):
	s = list(input().split(' '))
	num = int(s[0])
	for j in range(1, num + 1):
		if s[j] not in x:
			x.append(s[j])
x = set(list(map(int, x)))
if len(x) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ar = []
for i in range(n):
	temp = [int(n) for n in input().split()]
	ar += temp[1:len(temp)]
check = 0
for i in range(1, m + 1):
	if i in ar:
		check += 1
		if check == m:
			break
if check == m:
	print('YES')
else:
	print('NO')


def solve(m, s):
	return 'YES' if m == len(s) else 'NO'

def main():
	(n, m) = list(map(int, input().split()))
	s = set()
	for _ in range(n):
		a = list(map(int, input().split()))
		s = s.union(a[1:])
	print(solve(m, s))
main()


(n, m) = map(int, input().split())
bull = [False] * m
for i in range(n):
	botton = list(map(int, input().split()))[1:]
	for p in botton:
		bull[p - 1] = True
if False in bull:
	print('NO')
else:
	print('YES')


def solve(bulbs):
	for bulb in bulbs:
		if bulb is 0:
			return 'NO'
	return 'YES'
(n, m) = map(int, input().split(' '))
bulbs = [0] * m
for _n in range(0, n):
	vals = [int(y) for y in input().split()]
	vals.pop(0)
	for bulbIdx in vals:
		bulbs[bulbIdx - 1] = 1
print(solve(bulbs))


(n, m) = map(int, input().split())
x = []
for i in range(n):
	q = list(map(int, input().split()))
	q.pop(0)
	x += q
x = list(set(x))
print('YES' if len(x) == m else 'NO')


(n, m) = [int(i) for i in input().split()]
s = set()
for i in range(n):
	lst = [int(j) for j in input().split()]
	for elem in range(1, lst[0] + 1):
		s.add(lst[elem])
if len(s) != m:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split(' ')))
ans = []
for i in range(0, n, 1):
	x = list(map(int, input().split(' ')))
	for j in range(1, x[0] + 1, 1):
		if x[j] not in ans:
			ans.append(x[j])
		else:
			pass
if len(ans) >= m:
	print('YES')
else:
	print('NO')


def new():
	(x, y) = map(int, input().split())
	lst = list()
	for p in range(x):
		a = list(map(int, input().split()))
		lst += a[1:]
	lst = list(set(lst))
	print('YES') if len(lst) == y else print('NO')
new()


(a, p) = map(int, input().split())
(d, k) = ([], 0)
for x in range(a):
	b = []
	b.append(list(map(int, input().split())))
	for j in range(1, b[0][0] + 1):
		d.append(b[0][j])
m = list(set(d))
for x in range(1, p + 1):
	if x in m:
		k = 1
	else:
		k = 0
		print('NO')
		break
if k == 1:
	print('YES')


(n, m) = map(int, input().split())
ans = set()
for i in range(n):
	x = input().split()[1:]
	for entry in x:
		ans.add(entry)
print('YES' if len(ans) == m else 'NO')


a = [int(i) for i in input().split(' ')]
g = []
while a[0] > 0:
	a[0] -= 1
	b = [int(i) for i in input().split(' ')]
	g += [i for (j, i) in zip(range(len(b)), b) if j > 0]
s = set(g)
if len(s) == a[1]:
	print('YES')
else:
	print('NO')


inp = str(input()).split(' ')
n = int(inp[0])
m = int(inp[1])
bulbs = list(range(1, m + 1))
for i in range(n):
	inp = str(input()).split(' ')
	num = int(inp[0])
	for i in range(1, num + 1):
		bulb = int(inp[i])
		if bulb in bulbs:
			bulbs.remove(bulb)
		else:
			continue
if len(bulbs) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
myset = set()
for _ in range(n):
	a = list(map(int, input().split()))
	myset.update(a[1:])
if len(myset) == m:
	print('YES')
else:
	print('NO')


import sys
(N, M) = input().split(' ')
N = int(N)
M = int(M)
turnedOn = set()
for i in range(N):
	bulbs = list(map(int, input().split(' ')))[1:]
	for bulb in bulbs:
		turnedOn.add(bulb)
for i in range(1, M + 1):
	if i not in turnedOn:
		print('NO')
		sys.exit(0)
print('YES')


(n, m) = map(int, input().split())
bulbs = [False] * m
for i in range(n):
	l = [int(x) for x in input().split()]
	j = 1
	while j <= l[0]:
		if not bulbs[l[j] - 1]:
			bulbs[l[j] - 1] = True
		j += 1
for k in range(m):
	if not bulbs[k]:
		print('NO')
		break
else:
	print('YES')


def main():
	(n, m) = map(int, input().split())
	bulbs = [0] * m
	for _ in range(n):
		l = [int(x) for x in input().split()]
		yi = l[1:]
		for y in yi:
			bulbs[y - 1] += 1
	for x in bulbs:
		if x == 0:
			print('NO')
			return
	print('YES')
	return
main()


(n, m) = map(int, input().split())
lst = []
for i in range(n):
	for each in list(map(int, input().split()))[1:]:
		if each not in lst:
			lst.append(each)
if len(lst) == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
a = list()
for i in range(n):
	temp = list(map(int, input().split()))
	for i in temp[1:len(temp)]:
		a.append(i)
if len(set(a)) == m:
	print('YES')
else:
	print('NO')


(n, k) = [int(x) for x in input().split()]
s = set()
for i in range(n):
	arr = [int(x) for x in input().split()]
	s.update(arr[1:])
if len(s) >= k:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
num = 0
record = [0 for i in range(m)]
for i in range(n):
	si = [int(x) for x in input().split()]
	a = len(si)
	for i in range(1, a):
		if record[si[i] - 1] == 0:
			record[si[i] - 1] = 1
			num = num + si[i]
q = 0
for i in range(m + 1):
	q += i
if num == q:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
a = [1] * (m + 1)
for i in range(n):
	k = input().split()
	w = int(k[0])
	for j in range(w):
		x = int(k[j + 1])
		m -= a[x]
		a[x] = 0
if m == 0:
	print('YES')
else:
	print('NO')


intro = input()
variables = [int(x) for x in intro.split(' ')]
buttons = variables[0]
bulbs = variables[1]
onBulbs = set()
for button in range(buttons):
	connections = input().split(' ')
	for connection in connections[1:]:
		onBulbs.add(int(connection))
if onBulbs == set(range(1, bulbs + 1)):
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
ls = [0] * m
for _ in range(n):
	lt = [int(x) for x in input().split()]
	for i in range(1, len(lt)):
		ls[lt[i] - 1] = 1
if 0 in ls:
	print('NO')
else:
	print('YES')


nums = input().split()
bulbs = []
det = 1
n = int(nums[0])
m = int(nums[1])
for i in range(n):
	xy = input().split()
	bulbs.extend(xy[1:])
for j in range(1, m + 1):
	if bulbs.count(str(j)) == 0:
		det *= 0
if det == 0:
	print('NO')
else:
	print('YES')


import time
(n, m) = (int(i) for i in input().split())
a = [0 for i in range(m)]
for i in range(n):
	b = [int(i) for i in input().split()]
	for j in b[1:]:
		a[j - 1] = 1
start = time.time()
if 0 in a:
	print('NO')
else:
	print('YES')
finish = time.time()


(n, m) = map(int, input().split())
ll = []
for i in range(n):
	k = list(map(int, input().split()))
	for j in range(1, k[0] + 1):
		ll.append(k[j])
ll = set(ll)
ll = list(ll)
if ll == [int(i) for i in range(1, m + 1)]:
	print('YES')
else:
	print('NO')


(buttons, bulbs) = list(map(int, input().split(' ')))
status = [0] * (bulbs + 1)
status[0] = 1
for ll in range(buttons):
	numbers = list(map(int, input().split(' ')))
	for number in numbers[1:]:
		status[number] = 1
if status.count(0) == 0:
	print('YES')
else:
	print('NO')


(a, b) = [int(x) for x in input().split()]
bulb = set()
for i in range(a):
	e = input().split()
	bulb.update(set(e[1:]))
print(['NO', 'YES'][len(bulb) == b])


(n, m) = [int(x) for x in input().split(' ')]
y = list(range(1, m + 1))
for i in range(n):
	(k, *a) = [int(x) for x in input().split(' ')]
	for x in a:
		if x in y:
			y.remove(x)
if len(y) == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ans = set()
for i in range(n):
	xy = list(map(int, input().split()))
	xy.pop(0)
	ans = ans | set(xy)
if len(ans) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
set1 = set()
for i in range(n):
	lst1 = [int(x) for x in input().split()]
	lst1.pop(0)
	set2 = set(lst1)
	set1 = set2 | set1
if len(set1) == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
s = []
for i in range(1, m + 1):
	s.append(i)
counter = 0
for i in range(n):
	q = [int(x) for x in input().split()]
	q[0] = -1
	for k in q:
		if k in s:
			counter += 1
			s.remove(k)
if counter == m:
	print('YES')
else:
	print('NO')


a = input().split()
n = int(a[0])
m = int(a[1])
b = [0] * m
for i in range(n):
	a = input().split()
	a[0] = int(a[0])
	for j in range(1, a[0] + 1):
		a[j] = int(a[j])
		b[a[j] - 1] = 1
Dragon = True
for i in range(m):
	if b[i] == 0:
		Dragon = False
		break
if Dragon:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
r = set(range(1, m + 1))
for i in range(n):
	a = set(map(int, input().split()[1:]))
	r = r - a
print('YES' if len(r) == 0 else 'NO')


(a, b) = map(int, input().split())
k = []
for _ in range(a):
	c = list(map(int, input().split()))
	x = int(1)
	while x <= c[0]:
		k.append(c[x])
		x = x + 1
k = list(set(k))
if len(k) == b and max(k) == b:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
i = 1
l = list()
d = list()
for i in range(int(n)):
	x = input()
	l = x[1:].split()
	for v in l:
		if v not in d:
			d.append(v)
		else:
			continue
count = 0
for i in range(int(m)):
	for k in d:
		if i + 1 == int(k):
			count = count + 1
		else:
			continue
if count == int(m):
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [0] * m
for u in range(n):
	b = [int(i) for i in input().split()]
	for i in range(b[0]):
		a[b[i + 1] - 1] = 1
if sum(a) == m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split(' ')))
bulbs = []
for _ in range(n):
	nums = list(map(int, input().split(' ')))
	for i in range(1, len(nums)):
		bulbs.append(nums[i])
uniqueBulbs = set(bulbs)
if len(uniqueBulbs) == m:
	print('YES')
else:
	print('NO')


from collections import Counter
(n, m) = map(int, input().split())
c = Counter()
for i in range(n):
	(l, *arr) = list(map(int, input().split()))
	c.update(arr)
if len(c) == m:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
bulbs = [0] * n
for i in range(m):
	switch = list(map(int, input().split()))
	for i in range(switch[0]):
		bulbs[switch[i + 1] - 1] = 1
if 0 in bulbs:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
c = []
for i in range(n):
	(a, *b) = list(map(int, input().split()))
	z = b.copy()
	c = c + z
if m == len(set(c)):
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
li = []
for i in range(n):
	l = list(map(int, input().split()))
	l.pop(0)
	for i in l:
		li.append(i)
li = set(li)
if len(li) == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
bulb = [bool(False) for i in range(int(100.0 + 5))]
for i in range(n):
	arr = [int(i) for i in input().split(' ')]
	for j in range(1, len(arr)):
		bulb[arr[j]] = True
for i in range(1, m + 1):
	if not bulb[i]:
		print('NO')
		break
else:
	print('YES')


(n, m) = [int(x) for x in input().split()]
l = [1] * m
for x in range(n):
	lx = [int(x) for x in input().split()]
	for i in range(lx[0]):
		l[lx[i + 1] - 1] = 0
print(['YES', 'NO'][sum(l) != 0])


(n, m) = map(int, input().split())
a = []
for _ in ' ' * n:
	a += map(int, input().split()[1:])
print('YNEOS'[len(set(a)) != m::2])


(n, m) = list(map(int, input().split()))
c = []
i = 0
while i < n:
	a = list(map(int, input().split()))
	c += a[1:]
	i += 1
i = 0
c.sort()
c = set(c)
sum1 = 0
for x in c:
	if True:
		sum1 += x
sum2 = m * (m + 1) // 2
if sum2 == sum1:
	print('YES')
else:
	print('NO')


[no_intrerupatoare, no_becuri] = [int(x) for x in input().strip().split()]
v = [0] * 101
for i in range(no_intrerupatoare):
	becuri = [int(x) for x in input().strip().split()]
	for x in becuri[1:]:
		v[x] = 1
if sum(v) == no_becuri:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split(' ')]
l = set()
z = []
for _ in range(n):
	l = [int(x) for x in input().split(' ')]
	(n1, l1) = (l[0], l[1:])
	for x in l1:
		z.append(x)
a = set(z)
if len(a) == m:
	print('YES')
else:
	print('NO')


a = input().split()
n = int(a[0])
m = int(a[1])
l = [0] * m
for i in range(n):
	str1 = input().split()
	str2 = [int(x) for x in str1]
	for i in str2[1:]:
		l[i - 1] += 1
if 0 in l:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
b = list(range(1, m + 1))
for i in range(n):
	a = [int(n) for n in input().split()]
	for j in range(1, len(a)):
		p = a[j]
		if a[j] in b:
			b.remove(a[j])
if b == []:
	print('YES')
else:
	print('NO')


__author__ = 'Admin'
(n, m) = map(int, input().split())
b = []
a = [[int(j) for j in input().split()] for i in range(n)]
for i in range(m):
	b.append(i + 1)
for i in range(n):
	for j in range(1, len(a[i])):
		for k in range(len(b)):
			if a[i][j] == b[k]:
				b.pop(b.index(b[k]))
				break
		if len(b) == 0:
			break
if len(b) == 0:
	print('YES')
else:
	print('NO')


(k, l) = [int(j) for j in input().split()]
b = []
for i in range(l):
	b.append(0)
for i in range(k):
	a = [int(j) for j in input().split()]
	for j in range(1, a[0] + 1):
		b[a[j] - 1] = 1
x = 0
for i in b:
	if i == 1:
		x += 1
if x == l:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
bulbs = []
for i in range(n):
	s = list(map(int, input().split()))
	bulbs += s[1:]
bulbs_set = set(bulbs)
print(['NO', 'YES'][len(bulbs_set) == m])


(n, m) = [int(x) for x in input().split()]
a = []
s = 0
for i in range(n):
	b = [int(x) for x in input().split()]
	for j in range(b[0]):
		a.append(b[j + 1])
for i in range(1, m + 1):
	if i not in a:
		s = 1
		break
print(['YES', 'NO'][s])


(n, m) = map(int, input().split())
a = list(range(m))
for i in range(n):
	for elem in [e - 1 for e in list(map(int, input().split(' ')))[1:]]:
		a[elem] = -1
print('YES' if a.count(-1) == m else 'NO')


(n, k) = map(int, input().split())
s = {i for i in range(1, k + 1)}
for case in ' ' * n:
	s = s.difference(set(list(map(int, input().split()))[1:]))
print('YES' if len(s) == 0 else 'NO')


(x, y) = list(map(int, input().split()))
lista = []
ans = [0] * (y + 1)
for i in range(x):
	lista.append(list(map(int, input().split())))
for i in range(x):
	for j in range(1, len(lista[i])):
		ans[lista[i][j]] += 1
print(['YES', 'NO'][ans.count(0) > 1])


(m, n) = map(int, input().split())
s = []
for i in range(m):
	a = [int(x) for x in input().split()]
	a.remove(a[0])
	s += a
S = set(s)
print('YES' if len(S) == n else 'NO')


(n, m) = map(int, input().split())
buttns = []
for i in range(n):
	butt = input().split()[1:]
	if len(butt) != 0:
		butt = set(butt)
		buttns.append((len(butt), butt))
buttns.sort()
used = 0
lamps = set()
while (len(buttns) != 0 and used <= n) and len(lamps) != m:
	curr = buttns.pop()
	lamps = lamps | curr[1]
	used += 1
	for i in range(0, len(buttns)):
		buttns[i] = (len(buttns[i][1] - lamps), buttns[i][1])
	buttns.sort()
if used <= n and len(lamps) == m:
	print('YES')
else:
	print('NO')


q = list(map(int, input().split()))
w = [True] + [False for i in range(0, q[1])]
for i in range(0, q[0]):
	e = list(map(int, input().split()))
	r = e.pop(0)
	for j in e:
		w[j] = True
if w.count(True) == q[1] + 1:
	print('YES')
else:
	print('NO')