#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = int;
const ll mod = 998244353;


#include <list>
const ll inf = INT_MAX; //changeable 
ll Dinic_DFS(ll v,ll g,ll maxflow,vector<set<ll>>& lines, vector<map<ll,ll>>& cost,vector<ll>& level,vector<ll>& cap){

    if (v == g) return maxflow;
    cap[v] = 0;

    ll realflow = 0;
    vector<ll> tmp(0);
    for ( ll tmpv : lines[v] ) tmp.emplace_back(tmpv);

    for ( ll nex : tmp ){
        if (level[nex] > level[v] && (cap[nex] == 1)){
            ll plusflow = Dinic_DFS(nex,g,min(maxflow,cost[v][nex]),lines,cost,level,cap);
            cost[v][nex] -= plusflow;
            if (cost[v][nex] == 0) lines[v].erase(nex);
            if (cost[nex][v] == 0) lines[nex].insert(v);
            cost[nex][v] += plusflow;

            realflow += plusflow;
            maxflow -= plusflow;

            if (maxflow <= 0) return realflow;
        }
    }

    return realflow;
}

ll Dinic(ll s,ll g,vector<set<ll>>& lines, vector<map<ll,ll>>& cost){

    ll N = cost.size();
    ll ans = 0;
    vector<ll> level(N,inf);

    while (true){

        //bfs
        list<ll> q;
        q.emplace_back(s);
        rep(i,0,N) level[i] = inf;
        level[s] = 0;
        while (!q.empty()){
            ll now = q.front();
            q.pop_front();
            for ( ll nex : lines[now] ){
                if (level[nex] > level[now] + 1){
                    level[nex] = level[now] + 1;
                    q.emplace_back(nex);
                }
            }
        }

        if (level[g] == inf){
            return ans;
        }

        //dfs
        vector<ll> cap(N,1);
        ll delta_flow = Dinic_DFS(s,g,inf,lines,cost,level,cap);
        while (delta_flow > 0){
            ans += delta_flow;
            delta_flow = Dinic_DFS(s,g,inf,lines,cost,level,cap);
        }

    }
}

int main(){

    ll N;
    scanf ("%d" , &N);
    vector<vector<ll>> w(N-1,vector<ll> (0));
    vector<vector<ll>> vtoc(N,vector<ll> (0));

    rep(loop,0,N-1){
        ll c,wtmp;
        scanf ("%d" , &c);
        rep(i,0,c){
            scanf ("%d" , &wtmp);
            wtmp--;
            w[loop].emplace_back(wtmp);
            vtoc[wtmp].emplace_back(loop);
        }
    }

    vector<set<ll>> lines(2*N);
    vector<map<ll,ll>> cost(2*N);

    rep(i,1,N){
        lines[0].insert(i);
        cost[0][i] = 1;
    }
    rep(i,N+1,2*N){
        lines[i].insert(N);
        cost[i][N] = 1;
    }
    rep(i,0,N-1){
        for(ll j : w[i]){
            if (j != 0){
                lines[i+1].insert(N+j);
                cost[i+1][N+j] = 1;
            }
        }
    }

    ll flow = Dinic(0,N,lines,cost);
    if (flow != N-1){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> newv(N-1,-1);
    rep(i,0,N-1){
        for(ll j : w[i]){
            if (j != 0 && cost[i+1][N+j] == 0){
                newv[i] = j;
                break;
            }
        }
    }

    vector<ll> end(N,0);
    list<ll> q;
    q.emplace_back(0);
    vector<vector<ll>> ans(N-1,vector<ll> (2,-1));

    while (!q.empty()){

        ll nv = q.front();
        q.pop_front();

        for (ll c : vtoc[nv]){
            if (end[newv[c]] == 0){
                ans[c] = {nv+1,newv[c]+1};
                end[newv[c]] = 1;
                q.emplace_back(newv[c]);
            }
        }
    }

    ll ttf = 1;
    rep(i,0,N-1){
        if (ans[i][0] < 0) ttf = 0;
    }

    if (ttf){
        rep(i,0,N-1){
            printf ("%d %d\n",ans[i][0],ans[i][1]);
        }
    }else{
        cout << -1 << endl;
    }

    /* verify
    ll V,E;
    cin >> V >> E;

    vector<set<ll>> lines (V);
    vector<map<ll,ll>> cost (V);

    rep (i,0,E){
        ll u,v,c;
        cin >> u >> v >> c;
        if (c != 0){
            lines[u].insert(v);
            cost[u][v] += c;
        }
    }

    cout << Dinic(0,V-1,lines,cost) << endl;
    */
}

Measured memory_bytes: 94260