/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
bool dfs(int a, int layer, const vector<vi>& g, vi& btoa,vi& A, vi& B) {
	if (A[a] != layer) return 0;
	A[a] = -1;
	trav(b, g[a]) if (B[b] == layer + 1) {
		B[b] = -1;
		if (btoa[b] == -1 || dfs(btoa[b], layer+2, g, btoa, A, B))
			return btoa[b] = a, 1;
	}
	return 0;
}

int hopcroftKarp(const vector<vi>& g, vi& btoa) {
	int res = 0;
	vi A(g.size()), B(btoa.size()), cur, next;
	for (;;) {
		fill(all(A), 0);
		fill(all(B), -1);
		/// Find the starting nodes for BFS (i.e. layer 0).
		cur.clear();
		trav(a, btoa) if(a != -1) A[a] = -1;
		rep(a,0,sz(g)) if(A[a] == 0) cur.push_back(a);
		/// Find all layers using bfs.
		for (int lay = 1;; lay += 2) {
			bool islast = 0;
			next.clear();
			trav(a, cur) trav(b, g[a]) {
				if (btoa[b] == -1) {
					B[b] = lay;
					islast = 1;
				}
				else if (btoa[b] != a && B[b] == -1) {
					B[b] = lay;
					next.push_back(btoa[b]);
				}
			}
			if (islast) break;
			if (next.empty()) return res;
			trav(a, next) A[a] = lay+1;
			cur.swap(next);
		}
		/// Use DFS to scan for augmenting paths.
		rep(a,0,sz(g)) {
			if(dfs(a, 0, g, btoa, A, B))
				++res;
		}
	}
}
std::vector<vector<int>> g;
std::vector<int> btoa;
vector<pair<int,int>> adj[100005];
int n,c,dist[100005], p[100005], vis[100005], match[100005], a[100005],b[100005];
void bfstree(int s){
	queue<int> q;
	for(int i=1;i<=n;i++){
		vis[i]=0;
		dist[i]=inf;
	}
	dist[s]=0;
	q.push(s);
	while(!q.empty()){
		s = q.front();
		q.pop();
		if(vis[s])continue;
		vis[s]=1;
		//cout << s << endl;
		//dmp(s);
		for(auto t:adj[s]){
			//if(t.fs<=0)return;
			if(!vis[t.fs]){
					q.push(t.fs);
					b[t.sc]=s;
					//b[t.sc]=s;
			}
		}
	}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);

#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

cin >> n;
g.resize(2*n);
btoa.resize(2*n,-1);
for(int i=1;i<=n-1;i++){
	cin >> c;
	int x;
	for(int j=1;j<=c;j++){
		cin >> x;
		x--;
		g[i].pb(x);
	}
}
g[0].pb(0);
int m = hopcroftKarp(g,btoa);
//cout << m << endl;
if(m!=n){
	cout << -1 << endl;
	return 0;
}
for(int i=1;i<=n-1;i++){
	match[btoa[i]]=i;
}
for(int i=1;i<=n-1;i++){
	//cout << btoa[i] << endl;
	//match[btoa[i]]=i;
	for(auto t:g[i]){
		//adj[btoa[i]].pb(t);
		adj[t].pb({match[i],i});
		//dmp(t);
	}
}
int sum = 0,s=1;
bfstree(0);
for(int i=0;i<n;i++){
	sum+=vis[i];
	//if(!match[i])s=i;
}
//cout << s << endl;
//dmp(sum);
//assert(sum>=n);
if(sum!=n){
	cout << -1 << endl;
	return 0;
}

for(int i=1;i<=n-1;i++){
	cout << match[i]+1 << " " << b[i]+1 << endl;
}

return 0;}
///....


Measured memory_bytes: 22940