#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MaxN = 1e5 + 100;

vector<int> adj[MaxN];
int N;
bool visited[MaxN];
int match_left[MaxN], match_right[MaxN];
VI rev_adj[MaxN];

bool DfsMatch(int v) {
  if (visited[v]) { return false; }
  visited[v] = true;
  for (int s : adj[v]) {
    if (match_right[s] == -1 || DfsMatch(match_right[s])) {
      match_right[s] = v;
      match_left[v] = s;
      return true;
    }
  }
  return false;
}

int Matching() {
  fill_n(match_left, N, -1);
  fill_n(match_right, N, -1);
  int size = 0;
  bool has_incr;
  do {
    has_incr = false;
    fill_n(visited, N, false);
    for (int i = 0; i < N; ++i)
      if (match_left[i] == -1 && !visited[i] && DfsMatch(i)) {
        ++size;
        has_incr = true;
      }
  } while (has_incr);
  return size;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  cin >> N;
  for (int i = 1; i <= N - 1; ++i) {
    int sz;
    cin >> sz;
    for (int j = 0; j < sz; ++j) {
      int v; cin >> v;
      --v;
      adj[i].PB(v);
      rev_adj[v].PB(i);
    }
    adj[0].PB(i - 1);
  }

  if (Matching() != N) {
    cout << "-1\n";
    return 0;
  }

  for (int i = 0; i < N; ++i)
    debug(i, match_left[i]);

  vector<PII> edges(N - 1);
  int num_edges = 0;
  queue<int> Q;
  vector<bool> vis_set(N);
  vector<bool> vis_vert(N);

  Q.push(match_left[0]);
  vis_set[0] = true;
  vis_vert[match_left[0]] = true;

  while (!Q.empty()) {
    const int v = Q.front();
    Q.pop();

    for (int set_id : rev_adj[v]) {
      if (vis_set[set_id]) { continue; }
      vis_set[set_id] = true;
      const int s = match_left[set_id];
      assert(!vis_vert[s]);
      vis_vert[s] = true;
      debug(set_id, v, s);
      edges[set_id - 1] = make_pair(v, s);
      ++num_edges;
      Q.push(s);
    }
  }

  if (num_edges != N - 1) {
    cout << "-1\n";
    return 0;
  }

  for (auto &edge : edges)
    cout << edge.st + 1 << " " << edge.nd + 1 << "\n";
}



Measured memory_bytes: 17896