#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define ri register int
#define ptf printf
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 2e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib =  buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch) && !isdigit(ch)) ch = gc();
  while (isalpha(ch) || isdigit(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 998244353;//= 1e9 + 7;
  //int mod;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a - a / b * b, y, x);
  y -= a / b * x;
}
struct E { int v, nxt, c; };
const int N = 2e5 + 5;
int n, m;
vector <int> g[N];
namespace Flow {
  int d[N], cnt, fst[N], cur[N], s, t, ss, tt;
  E e[2000005];
  inline void init() {
    cnt = -1, s = 0, t = n + m + 1;
    for (ri i = s; i <= t; ++i) fst[i] = -1;
  }
  inline void addedge(int u, int v, int c) { e[++cnt] = (E) {v, fst[u], c}, fst[u] = cnt; }
  inline void _add(int u, int v, int c) {
    addedge(u, v, c);
    addedge(v, u, 0);
  }
  inline bool bfs() {
    queue <int> q;
    for (ri i = 0; i <= n + m + 4; ++i) d[i] = -1;
    q.push(s), d[s] = 0;
    while (q.size()) {
      int x = q.front();
      q.pop(), cur[x] = fst[x];
      for (ri i = fst[x], v; ~i; i = e[i].nxt) {
        if (~d[v = e[i].v] || e[i].c <= 0) continue;
        d[v] = d[x] + 1, q.push(v);
      }
    }
    return ~d[t];
  }
  inline int dfs(int x, int f) {
    if (x == t || !f) return f;
    int fl = f;
    for (ri &i = cur[x], v, tp; ~i; i = e[i].nxt) {
      if (!fl) return f;
      if (d[v = e[i].v] == d[x] + 1 && e[i].c > 0) {
        tp = dfs(v, min(fl, e[i].c));
        if (!tp) d[v] = -1;
        e[i].c -= tp, e[i ^ 1].c += tp, fl -= tp;
      }
    }
    return f - fl;
  }
  inline int solve() {
    int res = 0, tp;
    while (bfs()) while ((tp = dfs(s, inf)) > 0) res += tp;
    return res;
  }
  bool vs[N];
  pii ans[N];
  inline void Solve() {
    queue <int> q;
    q.push(1);
    int ct = 0;
    while (q.size()) {
      int x = q.front();
      q.pop();
      for (ri i = 0, v; i < g[x].size(); ++i) {
        if (vs[v = g[x][i] + n]) continue;
        vs[v] = 1;
        for (ri j = fst[v]; ~j; j = e[j].nxt) if (e[j].c > 0) {
          int _v = e[j].v;
          ans[v] = pii(x, _v);
          q.push(_v);
          ++ct;
        }
      }
    }
    if (!ct) cout << -1, exit(0);
    for (ri i = 1; i < n; ++i) cout << ans[i + n].fi << ' ' << ans[i + n].se << '\n';
  }
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read(), m = n - 1;
  Flow:: init();
  for (ri i = 1; i <= n; ++i) Flow:: _add(Flow:: s, i, 1);
  for (ri i = 1; i <= m; ++i) for (ri tt = read(); tt; --tt) {
    int x = read();
    g[x].pb(i);
    if (x > 1) Flow:: _add(x, n + i, 1);
  }
  for (ri i = 1; i <= m; ++i) Flow:: _add(i + n, Flow:: t, 1);
  if (Flow:: solve() != n - 1) return cout << -1, 0;
  Flow:: Solve();
  return 0;
}

Measured memory_bytes: 26696