#include #include using namespace std; using ll = long long; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int N; cin >> N; atcoder::scc_graph G(N); vector> H(N); for(int i = 0; i < N; i++) { int m; cin >> m; while(m--) { int a; cin >> a; a--; G.add_edge(i, a); H[i].push_back(a); } } auto scc = G.scc(); bool ok = false; for(int x: scc[0]) if(x == 0) ok = true; vector idx(N); for(int i = 0; i < scc.size(); i++) for(int x: scc[i]) idx[x] = i; vector T(scc.size() - 1); for(int i = 0; i < scc.size(); i++) for(int x: scc[i]) for(int y:H[x]) if(idx[y] == i + 1) T[i] = 1; bool ok1 = true; for(int i = 0; i < scc.size() - 1; i++) if(!T[i]) ok1 = false; cout << (ok && ok1 ? "Yes\n" : "No\n"); cerr << ok << " " << ok1 << endl; }