#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;struct edge{int to,next,rem;}e[1000005];
queue<int> q;pair<int,int> p[100005];vector<int> bel[100005];
int tot=1,s,t,n,last[1000005],dep[1000005],nxt[1000005],lst[1000005];
inline void adde(int u,int v,int d) {e[++tot]=(edge){v,last[u],d},last[u]=tot;return;}
inline void inse(int u,int v) {return adde(u,v,1),adde(v,u,0);}
inline bool bfs(void) {
	memset(dep,0,sizeof dep),dep[s]=1;
	while (!q.empty()) q.pop();q.push(s);
	while (!q.empty()) {int cur=q.front();q.pop();
		for (int i=last[cur];i;i=e[i].next) {int ot=e[i].to;
			if (e[i].rem&&!dep[ot]) dep[ot]=dep[cur]+1,q.push(ot);
		}
	}return dep[t];
}int dfs(int u,int lim) {int rtv=0,d;if (u==t) return lim;
	for (int&i=lst[u];i&&rtv<lim;i=e[i].next) {int ot=e[i].to;
		if (e[i].rem&&dep[ot]==dep[u]+1) {
			d=dfs(ot,min(e[i].rem,lim-rtv));
			e[i].rem-=d,e[i^1].rem+=d,rtv+=d;
		}
	}if (!rtv) dep[u]=0;return rtv;
}inline int prt(void) {int cnt=n;
	for (int i=1;i<n;++i) for (int j=last[i];j;j=e[j].next) {
		int ot=e[j].to;if (ot&&!e[j].rem) nxt[i]=ot-n;
	}while (!q.empty()) q.pop();q.push(n);
	while (!q.empty()) {int cur=q.front();q.pop(),--cnt;
		for (int i:bel[cur]) if (nxt[i])
			p[i]=make_pair(cur,nxt[i]),q.push(nxt[i]),nxt[i]=0;
	}return cnt;
}int main() {int m,u,fl=0;scanf("%d",&n),s=0,t=n<<1;
	for (int i=1;i<n;++i) inse(s,i),inse(n+i,t);
	for (int i=1;i<n;++i) {scanf("%d",&m);
		while (m--) {scanf("%d",&u);
			if (u^n) inse(i,n+u);bel[u].push_back(i);
		}
	}while (bfs()) memcpy(lst,last,sizeof last),fl+=dfs(s,0x3f3f3f3f);
	if (fl^(n-1)) return 0*puts("-1");if (prt()) return 0*puts("-1");
	for (int i=1;i<n;++i) printf("%d %d\n",p[i].first,p[i].second);return 0;
}