deadpool-and-his-valentine-3
Source: hackerearth
Difficulty: EASY

Deadpool wants to decorate his girlfriend’s house with a series of bulbs.  The number of bulbs is M. Initially, all the bulbs are switched off. Deadpool finds that there are K numbers of buttons, each of them is connected to a set of bulbs. Deadpool can press any of these buttons because he is DEADPOOL. When the button is pressed, it turns on all the bulbs it’s connected to. Can Deadpool accomplish his task to switch on all the bulbs?
If Deadpool 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.
Help him in his task to impress his valentine.

Here bulbs are numbered from 1 to M.

INPUT:::
The First line of Input contains integers K and M- the numbers of buttons and bulbs respectively.Each of the next K lines contains Xi  - the number of bulbs  that are turned on by the i-th button, and then Xi numbers Yij  — the numbers of these bulbs.

OUTPUT:::
If it's possible to turn on all m bulbs print "YES", otherwise print "NO" (quotes for clarity).

CONSTRAINTS:::
1 ≤ M,K ≤ 100,
0 ≤ Xi ≤ M,
1 ≤ Yij ≤ M.

SAMPLE INPUT
3 4
2 1 4
3 1 3 1
1 2

SAMPLE OUTPUT
YES


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
L=list(map(int, input().split()))
K=L[0]
M=L[1]
Bulbs=[]
Tot=(M*(M+1))/2
flag= False
for x in range(K):
	L=list(map(int, input().split()))
	for y in range(1, L[0]+1):
		if Tot==0:
			flag=True
			break
		elif not L[y] in Bulbs:
			Tot-=L[y]
			Bulbs.append(L[y])
	if flag:
		break
if Tot==0:
	print('YES')
else:
	print('NO')


try:	
	k,m=list(map(int,input().strip().split()))
	ti=0
	f=[]
	while ti<k:
		l=list(map(int,input().strip().split()))
		f.extend(l[1:])
		ti+=1
	f=list(set(f))
	if len(f)<m:
		print("NO")
	else:
		c=0
		i=1
		while i<=m:
			if i not in f:
				print("NO")
				c=99
				break
			i+=1
		if c==0:
			print("YES")
except:
	print("YES")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
L=list(map(int, input().split()))
K=L[0]
M=L[1]
Bulbs=[]
Tot=(M*(M+1))/2
flag= False
for x in range(K):
	L=list(map(int, input().split()))
	for y in range(1, L[0]+1):
		if Tot==0:
			flag=True
			break
		elif not L[y] in Bulbs:
			Tot-=L[y]
			Bulbs.append(L[y])
	if flag:
		break
if Tot==0:
	print('YES')
else:
	print('NO')


k, m = [int(i) for i in input('').split()]

states = [False for i in range(m)]

def main():
	for i in range(k):
		# import ipdb; ipdb.set_trace()
		for j in input('').split()[1:]:
			states[int(j)-1] = True
		if all(states):
			print('YES')
			return None
	print('NO')
		
		
if __name__ == '__main__':
	main()