#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long LL;

#define A first
#define B second

const int MAXN = 2e5+5;

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;
		}
	}
}

int n, m[MAXN], r[MAXN];
vector<int> g[MAXN];
vector<vector<int> > e;
pii ans[MAXN]; bool vis[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;
	e.resize(n-1);
	for (int i = 0; i < n-1; ++i) {
		int s;
		cin >> s;
		for (int j = 0; j < s; ++j) {
			int x; cin >> x;
			x--;
			e[i].push_back(x);
		}
	}

	vi ba(n, -1);
	int fl = hopcroftKarp(e, ba);
	if (fl < n-1) {
		cout << "-1\n";
		return 0;
	}
	ll s = 1LL*n*(n-1)/2;

	for (int i = 0; i < n; ++i) {
		if (ba[i] == -1)
			s = i;
		else {
			r[i] = ba[i];
			m[ba[i]] = i;
			// cout << ba[i] << ' ' << i << endl;
		}
	}
	//s is unmatched
	// cout << s << endl;
	for (int i = 0; i < n-1; ++i)
		for (int x : e[i])
			if (m[i] != x) {
				g[x].push_back(m[i]);
				// cout << x << ' ' << m[i] << endl;
			}

	//search from s
	queue<int> q;
	q.push(s);
	vis[s] = 1;
	int ct = 1;
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		for (int x : g[t]) {
			if (vis[x])
				continue;
			vis[x] = 1;
			ct++;
			q.push(x);
			ans[r[x]] = pii(x, t);
			// cout << r[x] << ' ' << x << ' ' << t << endl;
		}
	}
	if (ct < n) {
		cout << "-1\n";
		return 0;
	}

	for (int i = 0; i < n-1; ++i)
		cout << ans[i].A+1 << ' ' << ans[i].B+1 << "\n";
}