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.
import sys
from networkx.utils import UnionFind
def input(): return sys.stdin.readline().rstrip()


def main():
    n,m=map(int, input().split())
    lang=[[] for i in range(m+1)]
    for i in range(1,n+1):
        for talk in list(map(int, input().split()))[1:]:
            lang[talk].append(i)
    uf = UnionFind()
    for langs in lang:
        if len(langs) >=1:
            uf.union(*langs)
    print('Yes' if len(list(uf.to_sets()))==1 else 'No')
    




if __name__ == '__main__':
    main()
import sys
from networkx.utils import UnionFind
def input(): return sys.stdin.readline().rstrip()


def main():
    n,m=map(int, input().split())
    lang=[[] for i in range(m+1)]
    for i in range(1,n+1):
        for talk in list(map(int, input().split()))[1:]:
            lang[talk].append(i)
    uf = UnionFind()
    for langs in lang:
        if len(langs) >=1:
            uf.union(*langs)
    print('YES' if len(list(uf.to_sets()))==1 else 'NO')
    




if __name__ == '__main__':
    main()
