#include using namespace std; const int maxn = 2e4+5; bool vis[maxn]; int len [maxn]; vector> mp[maxn]; int T,n,u,v; int main (){ ios::sync_with_stdio(false); //freopen("in.txt","r",stdin); cin >> T; while (T--){ set se[105][12]; cin >> n; memset(vis,0,sizeof(vis)); memset(len,0,sizeof(len)); for (int i=0; i> len[i]; for (int j=0; j> u >> v; se[u][v].insert(i); mp[i].push_back(make_pair(u,v)); } } vis[0] = true; priority_queue,vector >,greater > > que; for (int i=0; i p = que.top(); que.pop(); //cout << p.first << ' ' << p.second << endl; for (auto &s : se[p.first][p.second]){ if (vis[s]) continue; vis[s] = 1; for (int i=0; i p.first) que.push(mp[s][i]); } } cout << 1; for (int i=1; i