Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define SZ(x) ((int)x.size())
#define fi first
#define se second
typedef long long LL;
typedef vector<int> vint;
const int N=400010;
int n;
namespace eden{
	int op,ed,cnt,head[N],cur[N];
	struct edge{
		int to,nxt,s;
	}e[N*2];
	void init(){
		cnt=1;
		memset(e,0,sizeof e);
		memset(head,0,sizeof head);
	}
	void add(int x,int y,int s){
		//cout<<x<<" "<<y<<endl;
		e[++cnt]=(edge){y,head[x],s};head[x]=cnt;
		e[++cnt]=(edge){x,head[y],0};head[y]=cnt;
	}
	queue<int> q; int dis[N+1];
	bool bfs(){
		q.push(op);
		ref(i,1,ed)dis[i]=1e9;dis[op]=0;
		while(!q.empty()){
			int u=q.front();q.pop();
			for(int i=head[u];i;i=e[i].nxt){
				int v=e[i].to;
				if(e[i].s&&dis[v]==(int)1e9)dis[v]=dis[u]+1,q.push(v);
			}
		}
		return dis[ed]!=1e9;
	}
	int dinic(int x,int f){
		if(x==ed)return f;
		int res=0;
		for(int&i=cur[x];i;i=e[i].nxt){
			int y=e[i].to;
			if(dis[y]==dis[x]+1&&e[i].s){
				int s=dinic(y,min(f,e[i].s));
				f-=s;res+=s;e[i].s-=s;e[i^1].s+=s;
			}
			if(!f)return res;
		}
		return res;
	}
	int flow(){
		int ans=0;while(bfs()){
			memcpy(cur,head,sizeof head);
			ans+=dinic(op,1e9);
		//cout<<ans<<endl;
		}return ans;
	}
}
using namespace eden;
vint E[N];
int link[N],ans[N]; bool vis[N];
int main(){
	cin>>n;
	op=n*2;ed=op+1;
	ref(i,1,n-1){
		int k,x;cin>>k;
		ref(j,1,k){cin>>x;E[x].pb(i);eden::add(x,i+n,1);}
	}
	ref(i,2,n)eden::add(op,i,1);
	ref(i,1,n-1)eden::add(i+n,ed,1);
	if(eden::flow()!=n-1)puts("-1");else{
		ref(i,2,n)for(int j=head[i];j;j=e[j].nxt)if(e[j].to!=op&&e[j].s==0)link[e[j].to-n]=i;
		queue<int> q;
		q.push(1);
		while(!q.empty()){
			int u=q.front();q.pop();
			ref(j,0,SZ(E[u])-1){
				int v=E[u][j];
				if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
			}
		}
		if(SZ(ans)!=n-1)puts("-1");else
			ref(i,1,n-1)cout<<ans[link[i]]<<" "<<link[i]<<endl;
	}
}

Compiler output:
a.cc:64:11: error: 'int link [400010]' redeclared as different kind of entity
   64 | int link[N],ans[N]; bool vis[N];
      |           ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'int main()':
a.cc:75:98: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   75 |                 ref(i,2,n)for(int j=head[i];j;j=e[j].nxt)if(e[j].to!=op&&e[j].s==0)link[e[j].to-n]=i;
      |                                                                                                  ^
a.cc:75:99: error: assignment of read-only location '*(link + ((sizetype)(eden::e[j].eden::edge::to - n)))'
   75 |                 ref(i,2,n)for(int j=head[i];j;j=e[j].nxt)if(e[j].to!=op&&e[j].s==0)link[e[j].to-n]=i;
      |                                                                                    ~~~~~~~~~~~~~~~^~
a.cc:82:66: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                                  ^
a.cc:82:59: error: no matching function for call to 'push(int (&)(const char*, const char*) noexcept)'
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                     ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' (near match)
  283 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:66: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'std::queue<int>::value_type' {aka 'int'} [-fpermissive]
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                            ~~~~~~^
      |                                                                  |
      |                                                                  int (*)(const char*, const char*) noexcept
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; value_type = int]' (near match)
  288 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note:   conversion of argument 1 would be ill-formed:
a.cc:82:66: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'std::queue<int>::value_type' {aka 'int'} [-fpermissive]
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                            ~~~~~~^
      |                                                                  |
      |                                                                  int (*)(const char*, const char*) noexcept
a.cc:82:79: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                                               ^
a.cc:82:72: error: invalid types 'int [400010][int(const char*, const char*) noexcept]' for array subscript
   82 |                                 if(!vis[v])vis[v]=1,q.push(link[v]),ans[link[v]]=u;
      |                                                                        ^
a.cc:6:23: error: request for member 'size' in 'ans', which is of non-class type 'int [400010]'
    6 | #define SZ(x) ((int)x.size())
      |                       ^~~~
a.cc:85:20: note: in expansion of macro 'SZ'
   85 |                 if(SZ(ans)!=n-1)puts("-1");else
      |                    ^~
a.cc:86:53: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   86 |                         ref(i,1,n-1)cout<<ans[link[i]]<<" "<<link[i]<<endl;
      |                                                     ^
a.cc:86:46: error: invalid types 'int [400010][int(const char*, const char*) noexcept]' for array subscript
   86 |                         ref(i,1,n-1)cout<<ans[link[i]]<<" "<<link[i]<<endl;
      |                                              ^
a.cc:86:68: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   86 |                         ref(i,1,n-1)cout<<ans[link[i]]<<" "<<link[i]<<endl;
      |                                                                    ^