#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 200228;
vector<int> e[N];
vector<int> erev[N];

int n;

int p[N];
int pr[N];

int w[N];
int curv;

int av[N], au[N];

void nein() {
    cout << -1 << "\n";
    exit(0);
}

bool dfs(int v) {
    if (w[v] == curv) {
        return false;
    }

    w[v] = curv;

    for (int u: e[v]) {
        if (p[u] == 0) {
            p[u] = v;
            return true;
        }
    }

    for (int u: e[v]) {
        if (dfs(p[u])) {
            p[u] = v;
            return true;
        }
    }

    return false;
}

bool go[N];

void dfsgo(int v) {
    go[v] = true;
    for (int u: erev[v]) {
        if (!go[pr[u]]) {
            av[u] = v;
            au[u] = pr[u];
            dfsgo(pr[u]);
        }
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);

    cin >> n;

    for (curv = 1; curv < n; ++curv) {
        int s;
        cin >> s;
        e[curv].resize(s);
        for (int& v: e[curv]) {
            cin >> v;
            erev[v].push_back(curv);
        }

        if (!dfs(curv)) {
            nein();
        }
    }

    for (int i = 1; i <= n; ++i) {
        pr[p[i]] = i;
    }

    int root = 1;
    while (p[root]) {
        ++root;
    }

    dfsgo(root);
    for (int i = 1; i <= n; ++i) {
        if (!go[i]) {
            nein();
        }
    }

    for (int i = 1; i < n; ++i) {
        cout << av[i] << " " << au[i] << "\n";
    }
}

