from networkx import*

print(('NYOE S'[is_connected(Graph((i,j)for i,t in[*enumerate(open(0))][1:]for j in t.split()[1:]))::2]))
from networkx import*

print(('NYOE S'[is_connected(Graph((t,j)for t in[*open(0)][1:]for j in t.split()[1:]))::2]))
from networkx import *

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

from networkx import *

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

-                Graph( -                    (i, j) for i, t in [*enumerate(open(0))][1:] for j in t.split()[1:] -                ) +                Graph((t, j) for t in [*open(0)][1:] for j in t.split()[1:])