//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 200111;
const int maxm = 400111*2;
int n;
int head[maxn], nxt[maxm], to[maxm], cap[maxm], tot=1;
void add_edge(int x, int y, int c)
{
	nxt[++tot] = head[x];
	head[x] = tot;
	to[tot] = y;
	cap[tot] = c;
	swap(x, y);
	nxt[++tot] = head[x];
	head[x] = tot;
	to[tot] = y;
	cap[tot] = 0;
}
int q[maxn], qn, dis[maxn];
void bfs(int S, int N)
{
	for (int i=0; i<=N; i++) dis[i] = -1;
	qn = 0;
	q[qn++] = S;
	dis[S] = 0;
	for (int i=0; i<qn; i++)
	{
		int x = q[i];
		for (int j=head[x]; j; j=nxt[j])
		{
			int u = to[j];
			if (cap[j]&&dis[u]==-1)
			{
				dis[u] = dis[x]+1;
				q[qn++] = u;
			}
		}
	}
}
int it[maxn];
int dfs(int x, int T, int f)
{
	if (x==T) return f;
	int of = f;
	for (int &i = it[x]; i; i=nxt[i])
	{
		int u = to[i];
		if (cap[i]&&dis[u]==dis[x]+1)
		{
			int d = dfs(u, T, min(f, cap[i]));
			if (d>0)
			{
				f -= d;
				cap[i] -= d;
				cap[i^1] += d;
				if (!f) return of;
			}
		}
	}
	return of-f;
}
int max_flow(int S, int T, int N)
{
	int flow = 0;
	while (true)
	{
		bfs(S, N);
		if (dis[T]==-1) return flow;
		for (int i=0; i<=N; i++) it[i] = head[i];
		int f;
		while (f = dfs(S, T, 1e9)) flow += f;
	}
}
int mt[maxn];
vector<int> v[maxn];
int ans[maxn];
int main()
{
	geti(n);
	int S = n+n, T = n+n+1;
	for (int i=2; i<=n; i++) add_edge(S, i, 1);
	for (int i=1; i<=n-1; i++)
	{
		add_edge(i+n, T, 1);
		int k;
		geti(k);
		for (int j=1; j<=k; j++)
		{
			int x;
			geti(x);
			add_edge(x, i+n, 1);
			v[x].PB(i);
		}
	}
	int f = max_flow(S, T, T);
	if (f!=n-1)
	{
		puts("-1");
	}
	else
	{
		for (int i=2; i<=n; i++)
		{
			for (int j=head[i]; j; j=nxt[j])
			{
				if (!cap[j]&&to[j]>n&&to[j]<n+n)
				{
					mt[to[j]-n] = i;
					break;
				}
			}
		}
		qn = 0; q[qn++] = 1;
		for (int i=0; i<qn; i++)
		{
			int x = q[i];
			for (auto u: v[x])
			{
				if (!ans[u])
				{
					ans[u] = x;
					q[qn++] = mt[u];
				}
			}
		}
		if (qn!=n)
		{
			puts("-1");
		}
		else
		{
			for (int i=1; i<=n-1; i++) putsii(ans[i], mt[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 27392