#include #include #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++) #define rep2ll(i,m,n) for(ll (i)=(m);(i)<(n);(i)++) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() using namespace std; using ll = long long; using P = pair; using mint = atcoder::modint998244353; using VL = vector; using VVL = vector; using VVVL = vector; using VM = vector; using VVM = vector; using VVVM = vector; using VD = vector; using VVD = vector; using VVVD = vector; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>n; VL m(n); VVL a(n); rep(i,n){ cin>>m[i]; a[i] = VL(m[i]); rep(j,m[i]) cin>>a[i][j], a[i][j]--; } atcoder::scc_graph g(n); rep(i,n) for(auto j:a[i]) g.add_edge(i, j); auto scc = g.scc(); bool b1 = false; for(auto x:scc[0]) b1 |= x == 0; bool b2 = true; int sz = scc.size(); VL b(n); rep(i,sz){ for(auto x:scc[i]) b[x] = i; } VL c(sz-1, 0); rep(i,n){ for(auto j:a[i]){ if(b[i] + 1 == b[j]){ c[b[i]] = 1; } } } rep(i,sz-1) b2 &= c[i]; cout<<(b1&&b2?"Yes\n":"No\n"); return 0; }