from atcoder.scc import SCCGraph N = int(input()) M, A = [], [] scc = SCCGraph(N) for i in range(N): m, *a = map(lambda x: int(x)-1, input().split()) M.append(m) A.append(a) for j in a: scc.add_edge(i, j) scc = scc.scc() label = [-1]*N for i, l in enumerate(scc): for j in l: label[j] = i to = [set() for _ in range(len(scc))] for i in range(N): for j in A[i]: if label[i] != label[j]: to[label[i]].add(label[j]) cnt_one = sum(len(x) == 1 for x in to) cnt_zero = sum(len(x) == 0 for x in to) if cnt_one == len(scc) - 1 and cnt_zero == 1: print("Yes") else: print("No")