def can_spread_to_all(N, connections): from collections import deque # グラフの隣接リストを構築 graph = [[] for _ in range(N + 1)] for i, conn in enumerate(connections, 1): for person in conn: graph[i].append(person) # BFSで到達可能なノードを探索 visited = [False] * (N + 1) queue = deque([1]) visited[1] = True while queue: current = queue.popleft() for neighbor in graph[current]: if not visited[neighbor]: visited[neighbor] = True queue.append(neighbor) # 全てのノードに訪問できたかチェック return all(visited[1:]) # 入力を読み込む import sys input = sys.stdin.read data = input().split() N = int(data[0]) index = 1 connections = [] for _ in range(N): M = int(data[index]) if M == 0: connections.append([]) else: connections.append([int(data[i]) for i in range(index + 1, index + M + 1)]) index += M + 1 if can_spread_to_all(N, connections): print("Yes") else: print("No")