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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

// O(V^2 E)
struct Dinic {
    using F = ll;
    static constexpr F INF = numeric_limits<F>::max();

    struct Edge {
        int to, rev;
        F cap;
        Edge(int to, F cap, int rev) : to(to), cap(cap), rev(rev){};
    };

    using E = Edge;

    VV<E> g;
    V<int> level, iter;

    Dinic() {}
    Dinic(int n) : g(n), level(n), iter(n) {}

    void add_edge(int from, int to, F cap) {
        g[from].emplace_back(to, cap, (int)g[to].size());
        g[to].emplace_back(from, 0, (int)g[from].size() - 1);
    }

    void bfs(int s) {
        fill(ALL(level), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);

        while (!que.empty()) {
            int v = que.front();
            que.pop();
            for (auto& e : g[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    F dfs(int v, int t, F f) {
        if (v == t) return f;
        for (int& i = iter[v]; i < g[v].size(); i++) {
            auto& e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                F 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;
    }

    F max_flow(int s, int t) {
        F flow = 0;
        while (true) {
            bfs(s);
            if (level[t] < 0) return flow;
            fill(ALL(iter), 0);
            F f;
            while ((f = dfs(s, t, INF)) > 0) flow += f;
        }
    }
};

VV<pii> gg;
V<bool> vis;
V<pii> ans;

void dfs(int v) {
    vis[v] = 1;
    for (auto e : gg[v]) {
        if (!vis[e.fi]) {
            ans[e.se] = mp(v, e.fi);
            dfs(e.fi);
        }
    }
}

int main() {
    int N;
    cin >> N;
    VV<int> E(N);
    rep(i, N - 1) {
        int k;
        cin >> k;
        rep(j, k) {
            int x;
            cin >> x;
            --x;
            E[i].pb(x);
        }
    }

    int r = 0;  // special
    Dinic flow(N + N + 2);
    int s = N * 2, t = s + 1;
    rep(i, N - 1) {
        flow.add_edge(i + N, t, 1);
        for (int x : E[i])
            if (x != r) {
                flow.add_edge(x, i + N, 1);
            }
    }
    rep(i, N) { flow.add_edge(s, i, 1); }
    int f = flow.max_flow(s, t);

    if (f != N - 1) {
        puts("-1");
        return 0;
    }

    V<int> rmt(N);
    for (int i = 1; i < N; ++i) {
        for (auto e : flow.g[i]) {
            if (e.to >= N && e.to < N + N - 1 && e.cap == 0) {
                rmt[e.to - N] = i;
            }
        }
    }
    debug(rmt);

    gg.resize(N);
    vis.resize(N);

    rep(i, N - 1) {
        for (int v : E[i]) {
            gg[v].eb(rmt[i], i);
        }
    }

    ans.resize(N - 1, mp(-1, -1));
    dfs(0);
    bool ok = 1;
    rep(i, N - 1) if (ans[i] == mp(-1, -1)) {
        puts("-1");
        return 0;
    }
    rep(i, N - 1) { cout << ans[i].fi + 1 << " " << ans[i].se + 1 << endl; }

    return 0;
}

Measured memory_bytes: 42864