from networkx import*

g=[]

for _,*t in[*list(map(str.split,open(i:=0)))][1:]:

 for j in t:g+=(i,'!'+j),

 i+=1

print(('NYOE S'[is_connected(Graph(g))::2]))
from networkx import*

g=[]

for t in[*open(i:=0)][1:]:

 for j in t.split()[1:]:g+=(i,'!'+j),

 i+=1

print(('NYOE S'[is_connected(Graph(g))::2]))
from networkx import *

g = []
for _, *t in [*list(map(str.split, open(i := 0)))][1:]:
    for j in t:
        g += ((i, "!" + j),)
    i += 1
print(("NYOE S"[is_connected(Graph(g)) :: 2]))

from networkx import *

g = []
for t in [*open(i := 0)][1:]:
    for j in t.split()[1:]:
        g += ((i, "!" + j),)
    i += 1
print(("NYOE S"[is_connected(Graph(g)) :: 2]))

-for _, *t in [*list(map(str.split, open(i := 0)))][1:]: -    for j in t: +for t in [*open(i := 0)][1:]: +    for j in t.split()[1:]: