#include<bits/stdc++.h>
using namespace std;
const int inf=2147483647;
#define N 100005
int n,m,S,T,cc=1,hd[1000005],iter[1000005],d[1000005],vis[N],t[N],t1[N],t2[N];
vector<int>g[N];
struct E{int v,nxt,w;}e[1000005];
void add(int u,int v,int w){e[++cc]=(E){v,hd[u],w};hd[u]=cc;e[++cc]=(E){u,hd[v],0};hd[v]=cc;}
bool bfs()
{
	for(int i=1;i<=T;i++)d[i]=inf;
	queue<int>q;q.push(S);d[S]=0;
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=hd[x];i;i=e[i].nxt)if(e[i].w&&d[e[i].v]==inf){d[e[i].v]=d[x]+1;q.push(e[i].v);}
	}
	return d[T]<inf;
}
int dfs(int x,int f)
{
	if(!f||x==T)return f;
	int sf=0;
	for(int &i=iter[x];i;i=e[i].nxt)if(e[i].w&&d[e[i].v]==d[x]+1)
	{
		int ff=dfs(e[i].v,min(f,e[i].w));
		if(ff){e[i].w-=ff;e[i^1].w+=ff;f-=ff;sf+=ff;}
	}
	return sf;
} 
int dinic()
{
	int ans=0;
	while(bfs())
	{
		memcpy(iter,hd,sizeof(iter));
		int f;while(f=dfs(S,inf))ans+=f;
	}
	return ans;
}
int main()
{
	scanf("%d",&n);S=1;T=2*n;
	for(int i=2;i<=n;i++)add(S,i,1);
	for(int i=n+1;i<2*n;i++)add(i,T,1);
	for(int i=2;i<=n;i++)
	{
		int sz;scanf("%d",&sz);
		while(sz--)
		{
			int x;scanf("%d",&x);
			g[x].push_back(i);
			if(x>1)add(i,x+n-1,1);
		}
	}
	if(dinic()!=n-1){puts("-1");return 0;}
	for(int i=2;i<=n;i++)for(int j=hd[i];j;j=e[j].nxt)if(!e[j].w)t[i]=e[j].v-n+1;
	queue<int>q;q.push(1);
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=0;i<g[x].size();i++)
		{
			int y=g[x][i];
			if(vis[y])continue;
			vis[y]=1;t1[y]=x;t2[y]=t[y];
			q.push(t[y]);
		} 
	}
	for(int i=2;i<=n;i++)if(!t1[i]){puts("-1");return 0;}
	for(int i=2;i<=n;i++)printf("%d %d\n",t1[i],t2[i]);
	return 0;
}