class UnionFind:

    def __init__(self, size):

        self.data = [-1] * size



    def find(self, x):

        if self.data[x] < 0:

            return x

        else:

            self.data[x] = self.find(self.data[x])

            return self.data[x]



    def union(self, x, y):

        x, y = self.find(x), self.find(y)

        if x != y:

            if self.data[y] < self.data[x]:

                x, y = y, x

            self.data[x] += self.data[y]

            self.data[y] = x

        return (x != y)



    def same(self, x, y):

        return (self.find(x) == self.find(y))



    def size(self, x):

        return -self.data[self.find(x)]





N, M = list(map(int, input().split()))

uf = UnionFind(N + M + 1)

used = set()

for i in range(1, N + 1):

    K, *L = list(map(int, input().split()))

    for l in L:

        uf.union(i, l + N)

        used.add(l)



if uf.size(1) - len(used) == N:

    print("YES")

else:

    print("NO")

class UnionFind:

    def __init__(self, size):

        self.data = [-1] * size



    def find(self, x):

        if self.data[x] < 0:

            return x

        else:

            self.data[x] = self.find(self.data[x])

            return self.data[x]



    def union(self, x, y):

        x, y = self.find(x), self.find(y)

        if x != y:

            if self.data[y] < self.data[x]:

                x, y = y, x

            self.data[x] += self.data[y]

            self.data[y] = x

        return (x != y)



    def same(self, x, y):

        return (self.find(x) == self.find(y))



    def size(self, x):

        return -self.data[self.find(x)]





N, M = list(map(int, input().split()))

uf = UnionFind(M + 1)

used = set()

for _ in range(N):

    K, *L = list(map(int, input().split()))

    for l in L:

        uf.union(L[0], l)

    used.update(L)



if uf.size(used.pop()) == 1 + len(used):

    print("YES")

else:

    print("NO")

class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size

    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return x != y

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

    def size(self, x):
        return -self.data[self.find(x)]


N, M = list(map(int, input().split()))
uf = UnionFind(N + M + 1)
used = set()
for i in range(1, N + 1):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(i, l + N)
        used.add(l)
if uf.size(1) - len(used) == N:
    print("YES")
else:
    print("NO")

class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size

    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return x != y

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

    def size(self, x):
        return -self.data[self.find(x)]


N, M = list(map(int, input().split()))
uf = UnionFind(M + 1)
used = set()
for _ in range(N):
    K, *L = list(map(int, input().split()))
    for l in L:
        uf.union(L[0], l)
    used.update(L)
if uf.size(used.pop()) == 1 + len(used):
    print("YES")
else:
    print("NO")

-uf = UnionFind(N + M + 1) +uf = UnionFind(M + 1) -for i in range(1, N + 1): +for _ in range(N): -        uf.union(i, l + N) -        used.add(l) -if uf.size(1) - len(used) == N: +        uf.union(L[0], l) +    used.update(L) +if uf.size(used.pop()) == 1 + len(used):