#include #include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n; cin >> n; vector g(n, vector()); atcoder::scc_graph sg(n); rep(u, n) { ll m; cin >> m; rep(mi, m) { ll v; cin >> v, v--; g[u].push_back(v); sg.add_edge(u, v); } } auto res = sg.scc(); bool ok = true; set st = {0}; for (const auto &now : res) { bool found = false; set nex; for (const auto u : now) { found |= st.count(u); for (const auto v : g[u]) nex.insert(v); } ok &= found; if (!ok) break; swap(st, nex); } cout << (ok ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }