#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

/*
struct E {
    int to, rev, cap;
};
VV<E> g;
auto add_edge = [&](int from, int to, int cap) {
    g[from].push_back(E{to, int(g[to].size()), cap});
    g[to].push_back(E{from, int(g[from].size())-1, 0});
};
*/

template<class C>
struct MaxFlow {
    C flow;
    V<char> dual;  // false: S-side true: T-side
};

template<class C, class E>
struct MFExec {
    static constexpr C INF = numeric_limits<C>::max();
    C eps;
    VV<E>& g;
    int s, t;
    V<int> level, iter;

    C dfs(int v, C f) {
        if (v == t) return f;
        C res = 0;
        for (int& i = iter[v]; i < int(g[v].size()); i++) {
            E& e = g[v][i];
            if (e.cap <= eps || level[v] >= level[e.to]) continue;
            C d = dfs(e.to, min(f, e.cap));
            e.cap -= d;
            g[e.to][e.rev].cap += d;
            res += d;
            f -= d;
            if (f == 0) break;
        }
        return res;
    }

    MaxFlow<C> info;
    MFExec(VV<E>& _g, int _s, int _t, C _eps)
            : eps(_eps), g(_g), s(_s), t(_t) {
        int N = int(g.size());

        C& flow = (info.flow = 0);
        while (true) {
            queue<int> que;
            level = V<int>(N, -1);
            level[s] = 0;
            que.push(s);
            while (!que.empty()) {
                int v = que.front(); que.pop();
                for (E e: g[v]) {
                    if (e.cap <= eps || level[e.to] >= 0) continue;
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
            if (level[t] == -1) break;
            iter = V<int>(N, 0);
            while (true) {
                C f = dfs(s, INF);
                if (!f) break;
                flow += f;
            }
        }
        for (int i = 0; i < N; i++) info.dual.push_back(level[i] == -1);
    }
};

template<class C, class E>
MaxFlow<C> get_mf(VV<E>& g, int s, int t, C eps) {
    return MFExec<C, E>(g, s, t, eps).info;
}

void imp() {
    cout << -1 << endl;
    exit(0);
}

struct E {
    int to, rev, cap;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n;
    cin >> n;
    int v = n + n - 1 + 2;
    VV<E> g(v);
    int sv = n + n - 1, tv = sv + 1;

    auto add_edge = [&](int from, int to, int cap) {
        g[from].push_back(E{to, int(g[to].size()), cap});
        g[to].push_back(E{from, int(g[from].size())-1, 0});
    };

    for (int i = 0; i < n-1; i++) {
        add_edge(sv, i, 1);
    }
    for (int i = 0; i < n; i++) {
        add_edge(n - 1 + i, tv, 1);
    }

    for (int i = 0; i < n-1; i++) {
        int c;
        cin >> c;
        for (int j = 0; j < c; j++) {
            int x;
            cin >> x; x--;
            add_edge(i, n - 1 + x, 1);
        }
    }
    auto mf = get_mf<int>(g, sv, tv, 0);
    if (mf.flow != n-1) imp();

    V<int> mt1(n - 1, -1), mt2(n - 1, -1);
    VV<int> g2(v);
    auto add_e2 = [&](int s, int t) {
        //cerr << "E2 " << s << " -> " << t << endl;
        g2[s].push_back(t);
    };
    for (int i = n - 1; i < n + n - 1; i++) {
        for (auto e: g[i]) {
            if (e.to < n - 1) {
                if (e.cap) {
                    mt1[e.to] = i - (n - 1);
                    add_e2(e.to, i);
                } else {
                    add_e2(i, e.to);
                }
            } else if (e.to == tv) {
                if (e.cap) {
                    cerr << "FIND Unused : " << i - (n - 1) << endl;
                    add_e2(tv, i);
                }
            } else assert(false);
        }
    }

    V<int> prev(v, -1);
    queue<int> q;
    q.push(tv);
    prev[tv] = -2;
    while (!q.empty()) {
        int p = q.front(); q.pop();
        for (int d: g2[p]) {
            if (prev[d] != -1) continue;
            prev[d] = p;
            q.push(d);
        }
    }
    for (int i = 0; i < n - 1; i++) {
        if (prev[i] == -1) imp();
        mt2[i] = prev[i] - (n - 1);
        cout << mt1[i] + 1 << " " << mt2[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 33668