#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class Dinic {
	struct edge {
		int to;
		T cap, icap;
		int rev;
	};
	vector<vector<edge>> graph;
	vector<int> level, iter;
public:
	Dinic(int n) {
		graph = vector<vector<edge>>(n, vector<edge>());
		level = iter = vector<int>(n);
	}
	void add_edge(int from, int to, T cap) {
		graph[from].push_back({ to,cap,cap,(int)graph[to].size() });
		graph[to].push_back({ from,0,0,(int)graph[from].size() - 1 });
	}
	void bfs(int s) {
		for (int &i : level) i = -1;
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (int i = 0; i < graph[v].size(); i++) {
				edge &e = graph[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	T dfs(int v, int t, T f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < graph[v].size(); i++) {
			edge &e = graph[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				T d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s, int t) {
		T flow = 0;
		while (true) {
			bfs(s);
			if (level[t] < 0) return flow;
			for (int &i : iter) i = 0;
			T f = 0;
			while ((f = dfs(s, t, inf)) > 0) flow += f;
		}
	}
	vector<P> bipartite_matching(int s, int t) {
		vector<P> res;
		max_flow(s, t);
		for (int i = 0; i < graph.size(); i++) {
			if (i == s) continue;
			for (edge e : graph[i]) {
				if (e.cap == 0 && e.icap == 1 && e.to != t) {
					res.push_back({ i,e.to });
				}
			}
		}
		return res;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	Dinic<int> flow(2 * n + 2);
	vector<vector<int>> pl(n, vector<int>());
	rep(i, n - 1) {
		int sz;
		cin >> sz;
		rep(j, sz) {
			int v;
			cin >> v;
			v--;
			pl[v].pb(i);
			flow.add_edge(i, n + v, 1);
		}
	}
	rep(i, n) {
		flow.add_edge(2 * n, i, 1);
		flow.add_edge(n + i, 2 * n + 1, 1);
	}
	vector<P> match = flow.bipartite_matching(2 * n, 2 * n + 1);
	sort(all(match));
	if (match.size() != n - 1) {
		cout << "-1\n";
		return 0;
	}
	vector<P> ans(n - 1);
	rep(i, n - 1) ans[i].first = match[i].second - n;
	vector<bool> ap(n);
	rep(i, n - 1) ap[ans[i].first] = true;
	int st = -1;
	rep(i, n) if (!ap[i]) st = i;
	vector<bool> vis(n), use(n - 1);
	vis[st] = true;
	queue<int> que;
	que.push(st);
	while (!que.empty()) {
		int q = que.front(); que.pop();
		for (int i : pl[q]) {
			if (!use[i] && !vis[ans[i].first]) {
				ans[i].second = q;
				use[i] = true;
				vis[ans[i].first] = true;
				que.push(ans[i].first);
			}
		}
	}
	bool ok = true;
	rep(i, n) if (!vis[i]) ok = false;
	if (ok) rep(i, n - 1) cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
	else cout << "-1\n";
}

Measured memory_bytes: 39844