On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.  For _CODE FESTIVAL 20XX_ held on this planet, N participants gathered from all over the planet.  The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.  Two participants A and B can _communicate_ with each other if and only if one of the following conditions is satisfied:    * There exists a language that both A and B can speak.   * There exists a participant X that both A and B can communicate with.  Determine whether all N participants can communicate with all other participants.
N,M=map(int,input().split())  

par=[i for i in range(N+M)]
rank=[0]*(N+M)
friend=[0]*(N+M)
block=[0]*(N+M)
size=[1]*(N+M)

def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]


def same(x,y):
  return find(x)==find(y)

def union(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 
  if rank[x]>rank[y]:
    par[y]=x
    size[x]+=size[y]
  else:
    par[x]=y
    size[y]+=size[x]
    if rank[x]==rank[y]:
      rank[y]+=1


for i in range(N):
  A=list(map(int, input().split()))
  a=A[0]
  A=A[1:]
  for j in A:
    union(i,N+j-1)
D=[]
for i in range(N):
  D.append(find(i))
if len(set(D))==1:
  print('Yes')
else:
  print('No')
N,M=map(int,input().split())  

par=[i for i in range(N+M)]
rank=[0]*(N+M)
friend=[0]*(N+M)
block=[0]*(N+M)
size=[1]*(N+M)

def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]


def same(x,y):
  return find(x)==find(y)

def union(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 
  if rank[x]>rank[y]:
    par[y]=x
    size[x]+=size[y]
  else:
    par[x]=y
    size[y]+=size[x]
    if rank[x]==rank[y]:
      rank[y]+=1


for i in range(N):
  A=list(map(int, input().split()))
  a=A[0]
  A=A[1:]
  for j in A:
    union(i,N+j-1)
D=[]
for i in range(N):
  D.append(find(i))
if len(set(D))==1:
  print('YES')
else:
  print('NO')