// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = (int) 1e5;

namespace FLOW
{
	const int INF = (int) 1e9;
	const int MAXV = MAXN * 2, MAXE = MAXN * 8;

	int cnt;

	inline int new_node() { return ++cnt; }

	struct edge
	{
		int v, c, nxt;

		edge() { }
		edge(int _v, int _c, int _nxt): v(_v), c(_c), nxt(_nxt) { }
	};

	edge e[MAXE * 2 + 5];
	int st[MAXV + 5], edge_cnt;

	inline void init() { cnt = 0, memset(st, -1, sizeof st), edge_cnt = 0; }
	inline int add_edge(int u, int v, int c, int type = 1)
	{
		e[edge_cnt] = edge(v, c, st[u]), st[u] = edge_cnt++;
		if(type) add_edge(v, u, 0, 0);
		return st[u];
	}

	int d[MAXV + 5];

	inline int BFS(int S, int T)
	{
		static queue<int> q;
		for(int i = 1; i <= cnt; ++i) d[i] = -1;

		d[S] = 0, q.push(S);
		while(!q.empty())
		{
			int u = q.front();
			q.pop();

			for(int i = st[u]; ~i; i = e[i].nxt)
			{
				int v = e[i].v;
				if(e[i].c > 0 && d[v] == -1) d[v] = d[u] + 1, q.push(v);
			}
		}

		return d[T] != -1;
	}

	int cur[MAXV + 5];

	inline int dfs(int u, int low, int T)
	{
		if(u == T) return low;

		int sum = 0;
		for(int &i = cur[u]; ~i; i = e[i].nxt)
		{
			int v = e[i].v, k = 0;
			if(e[i].c > 0 && d[v] == d[u] + 1 && (k = dfs(v, min(low, e[i].c), T)) > 0)
			{
				e[i].c -= k, e[i ^ 1].c += k;
				sum += k, low -= k;
				if(low == 0) break;
			}
		}
		return sum;
	}

	inline int solve(int S, int T)
	{
		int flow = 0;
		while(BFS(S, T))
		{
			for(int i = 1; i <= cnt; ++i) cur[i] = st[i];
			for(int k = dfs(S, INF, T); k > 0; k = dfs(S, INF, T)) flow += k;
		}
		return flow;
	}
}

int n;

vector<int> E[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i) for(int N = read<int>(); N--; ) E[i].push_back(read<int>());
}

int d[MAXN + 5], id[MAXN + 5];
vector<int> ids[MAXN + 5];

int fa[MAXN + 5];

inline int dfs(int u)
{
	int res = 1;
	for(auto v0 : ids[u]) if(!fa[v0])
	{
		int v = d[v0];
		fa[v0] = u;
		res += dfs(v);
	}
	return res;
}

inline void solve()
{
	FLOW::init();

	static unordered_map<int, int> eid[MAXN + 5];
	static int X[MAXN + 5], Y[MAXN + 5];

	const int S = FLOW::new_node(), T = FLOW::new_node();
	for(int i = 1; i < n; ++i) FLOW::add_edge(S, X[i] = FLOW::new_node(), 1);
	for(int i = 1; i < n; ++i) FLOW::add_edge(Y[i] = FLOW::new_node(), T, 1);

	for(int i = 1; i < n; ++i) for(auto j : E[i]) if(j != n)
		eid[i][j] = FLOW::add_edge(X[i], Y[j], 1);

	if(FLOW::solve(S, T) != n - 1) { puts("-1"); return; }

	for(int i = 1; i < n; ++i)
		for(auto j : E[i]) if(eid[i].count(j) && FLOW::e[eid[i][j]].c == 0)
		{
			d[i] = j, id[j] = i;
			break;
		}

	for(int i = 1; i < n; ++i) for(auto j : E[i]) ids[j].push_back(i);
	if(dfs(n) != n) { puts("-1"); return; }
	for(int i = 1; i < n; ++i) printf("%d %d\n", d[i], fa[i]);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 45952