#include using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a> g,rg; vector used; vector ord; vector comp; SCC(int x){ n=x; g.resize(n); rg.resize(n); used.resize(n,false); comp.resize(n,-1); } void add_edge(int u,int v){ g[u].push_back(v); rg[v].push_back(u); } void dfs(int x){ used[x]=true; for(auto &i:g[x]){ if(!used[i]) dfs(i); } ord.push_back(x); } void rdfs(int x,int cnt){ comp[x]=cnt; for(auto &i:rg[x]){ if(comp[i]==-1) rdfs(i,cnt); } } vector> solve(){ for(int i=0;i> ret(cnt); for(int i=0;i> n; vector> g(n); rep(i,n){ ll m; cin >> m; rep(j,m){ ll a; cin >> a; a--; g[i].push_back(a); } } SCC s(n); rep(i,n){ for(auto j:g[i]) s.add_edge(i,j); } vector> ret=s.solve(); ll sz=len(ret); vector> st(sz); vector v(n); rep(i,sz){ for(auto j:ret[i]){ st[i].insert(j); v[j]=i; } } vector> h(sz); rep(i,sz){ for(auto j:ret[i]){ for(auto k:g[j]){ if(st[i].contains(k)) continue; h[i].insert(v[k]); } } } vector dp(sz,0); rep(i,sz){ if(st[i].contains(0)) dp[i]=1; } rep(i,sz){ for(auto j:h[i]){ dp[j]+=dp[i]; } } rep(i,sz){ if(dp[i]!=1){ cout << "No\n"; return 0; } } cout << "Yes\n"; }