/*

  _|_|                              _|  _|    _|
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|
_|    _|  _|_|          _|          _|  _|_|
_|    _|  _|          _|      _|    _|  _|  _|
  _|_|    _|        _|_|_|_|    _|_|    _|    _|

*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
const int maxn=4e5+1000;
const int inf=1e9+100;
using namespace std;
vi E[maxn],inset[maxn];
int s=2e5+1,t=2e5+2,cnt=1,head[maxn];
struct gg{
    int u,v,w,next;
}side[maxn*2];
void ins(int u,int v,int w) {
    side[++cnt]=(gg){u,v,w,head[u]};head[u]=cnt;
    side[++cnt]=(gg){v,u,0,head[v]};head[v]=cnt;
}
int rk[maxn],cur[maxn];
queue<int>q;
bool bfs() {
    memset(rk,0,sizeof(rk));rk[s]=1;
    while(!q.empty())q.pop();q.push(s);
    while(!q.empty()) {
        int u=q.front();q.pop();
        for(int i=head[u];i;i=side[i].next) {
            int v=side[i].v;if(rk[v]||!side[i].w)continue;
            rk[v]=rk[u]+1;
            q.push(v);
        }
    }
    if(!rk[t])return 0;
    return 1;
}
int dfs(int u,int flow) {
    if(u==t||!flow)return flow;
    int tot=0;
    for(int &i=cur[u];i&&flow;i=side[i].next) {
        int v=side[i].v;//cout<<v<<' '<<rk[v]<<endl;
        if(rk[v]!=rk[u]+1||!side[i].w)continue;
        int sent=dfs(v,min(flow,side[i].w));
        side[i].w-=sent;side[i^1].w+=sent;
        flow-=sent;tot+=sent;
    }
    return tot;
}
int dinic(){
    int maxflow=0;
    while(bfs()){
        memcpy(cur,head,sizeof(cur));
        maxflow+=dfs(s,inf);
    }
    return maxflow;
}
int match[maxn];//match[set_id]=match_point_id
bool inq[maxn];
pii ans[maxn];
int main(){
    //ios::sync_with_stdio(0);
    int n;scanf("%d",&n);//cin>>n;
    rep(i,1,n-1) {
        int c;scanf("%d",&c);//cin>>c;
        rep(j,1,c) {
            int u;scanf("%d",&u);//cin>>u;
            E[i].pb(u);inset[u].pb(i);
            ins(u,n+i,1);
        }
    }
    rep(i,2,n)ins(s,i,1);
    rep(i,1,n-1)ins(n+i,t,1);
    int flow=dinic();
    if(flow!=n-1) {
        printf("-1\n");//cout<<"-1";
        return 0;
    }
    rep(i,n+1,n+n-1) {
        for(int j=head[i];j;j=side[j].next) {
            int v=side[j].v;
            if(v<=n&&side[j].w) {
                match[i-n]=v;break;
            }
        }
    }
    while(!q.empty())q.pop();
    int tot=1;q.push(1);inq[1]=1;
    while(!q.empty()) {
        int u=q.front();q.pop();
        for(int i=0;i<inset[u].size();i++) {
            int setid=inset[u][i],set_match=match[setid];
            if(!inq[set_match]) {
                inq[set_match]=1;ans[setid]=mk(u,set_match);
                q.push(set_match);tot++;
            }
        }
    }
    if(tot!=n) {
        printf("-1\n");//cout<<"-1";
        return 0;
    }
    for(int i=1;i<n;i++) {
        printf("%d %d\n",ans[i].fi,ans[i].se);
        //cout<<ans[i].fi<<' '<<ans[i].se<<endl;
    }
    return 0;
}

Measured memory_bytes: 52788