#include <bits/stdc++.h>
using namespace std;
int head[200010];
int cur[200010];
struct edge {
    int v, c, next;
    edge() {}
    edge(int _v, int _c, int _next) : v(_v), c(_c), next(_next) {}
} e[1500010];
int n, s, t;
int newedge(int v = 0, int c = 0, int next = 0) {
    static int tot = 2;
    return e[tot] = edge(v, c, next), tot++;
}
void addedge(int u, int v, int c) {
    head[u] = newedge(v, c, head[u]);
    head[v] = newedge(u, 0, head[v]);
}
int d[200010];
int bfs() {
    memset(d, -1, sizeof d);
    queue < int > q;
    q.push(0);
    d[s] = 1;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int i = head[now]; i; i = e[i].next)
            if (e[i].c > 0 && d[e[i].v] == -1)
                d[e[i].v] = d[now] + 1, q.push(e[i].v);
    }
    memcpy(cur, head, sizeof cur);
    return d[t] > 0;
}
int dfs(int now = 0, int limit = 0x7fffffff) {
    if (now == t)
        return limit;
    int ans = 0;
    for (int &i = cur[now]; i; i = e[i].next) {
        if (d[e[i].v] != d[now] + 1 || e[i].c == 0)
            continue;
        int a = dfs(e[i].v, min(e[i].c, limit));
        limit -= a;
        ans += a;
        e[i].c -= a;
        e[i ^ 1].c += a;
        if (limit == 0)
            break;
    }
    return ans;
}
int tmp[200010], to[200010], fa[200010];
int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int cnt;
        scanf("%d", &cnt);
        while (cnt--) {
            int x;
            scanf("%d", &x);
            addedge(i, n - 1 + x, 1);
        }
    }
    s = 0, t = n + n;
    memcpy(tmp, head, sizeof tmp);
    for (int i = 1; i < n; i++) addedge(s, i, 1), addedge(i + n - 1, t, 1);
    int ans = 0;
    while (bfs())
        ans += dfs();
    memcpy(head, tmp, sizeof tmp);
    if (ans != n - 1) return puts("-1"), 0;
    for (int i = 1; i < n; i++) {
        for (int j = head[i]; j; j = e[j].next) if (e[j].c == 0) assert(to[i] == 0), to[i] = e[j].v - n + 1;
        assert(to[i] < n);
        assert(to[i]);
    }
    queue < int > q;
    q.push(n);
    int cnt = 0;
    while (!q.empty()) {
        cnt++;
        int now = q.front();
        q.pop();
        for (int i = head[now + n - 1]; i; i = e[i].next) {
            if (!fa[e[i].v]) {
                q.push(to[e[i].v]);
                fa[e[i].v] = now;
            }
        }
    }
    if (cnt != n) return puts("-1"), 0;
    for (int i = 1; i < n; i++) printf("%d %d\n", fa[i], to[i]);
}