#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////


namespace MF { //init before you use it. when you use double, be careful.
	struct edge { int to, cap, rev; };

	vector<edge> G[MAX_N];
	int level[MAX_N];
	int iter[MAX_N];

	void init(int n) {
		rep(i, 0, n) G[i].clear();
	}

	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge){to, cap, (int)G[to].size()});
		G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
	}

	void bfs(int s) {
		memset(level, -1, sizeof(level));
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while(!que.empty()) {
			int v = que.front(); que.pop();
			for(int i = 0; i < (int)G[v].size(); i++) {
				edge &e = G[v][i];
				if(e.cap > 0 && level[e.to] == -1) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if(v == t) return f;
		for(int &i = iter[v]; i < (int)G[v].size(); i++) {
			edge &e = G[v][i];
			if(e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if(d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll get(int s, int t) {
		ll flow = 0;
		while(true) {
			bfs(s);
			if(level[t] == -1) return flow;
			memset(iter, 0, sizeof(iter));
			int f;
			while((f = dfs(s, t, inf)) > 0) {
				flow += f;
			}
		}
	}
}

int N;
int used[MAX_N];

void loop(int v, int p) {
	// debug(v, p);
	if(v < N - 1) used[v] = p - (N - 1);
	else used[v] = 0;
	rep(i, 0, sz(MF::G[v])) {
		auto& e = MF::G[v][i];
		if(e.cap == 0 && used[e.to] == -1 && e.to < 2 * N - 1) loop(e.to, v);
	}
}

void solve() {
	cin >> N;
	int S = 2 * N - 1, T = 2 * N;
	MF::init(2 * N + 1);
	rep(i, 0, N - 1) {
		int a; cin >> a;
		while(a--) {
			int b; cin >> b; b--;
			MF::add_edge(i, b + N - 1, 1);
		}
	}
	rep(i, 0, N - 1) MF::add_edge(S, i, 1);
	rep(i, 0, N) MF::add_edge(i + N - 1, T, 1);
	if(MF::get(S, T) != N - 1) {
		cout << -1 << "\n"; return;
	}
	rep(i, 0, N - 1) {
		rep(j, 0, sz(MF::G[i])) {
			auto& e = MF::G[i][j];
			if(e.cap == 0) {
				used[e.to] = 1;
				// debug(i, e.to);
			}
		}
	}
	int root = -1;
	rep(i, 0, N) {
		if(!used[i + N - 1]) {
			root = i + N - 1;
			break;
		}
	}
	memset(used, -1, sizeof(used));
	loop(root, -1);
	rep(i, 0, N - 1) {
		if(used[i] == -1) {
			cout << -1 << "\n"; return;
		}
	}
	rep(i, 0, N - 1) {
		rep(j, 0, sz(MF::G[i])) {
			auto& e = MF::G[i][j];
			if(e.cap == 0) {
				cout << e.to - (N - 1) + 1 << " " << used[i] + 1 << "\n";
			}
		}
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 39476