#include <bits/stdc++.h>
using namespace std;
bitset<2010> a[2010], an, c[2010], qu;
map<bitset<2010>, int> g;
int m, n, x, y, d[2010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    for (int j = 1; j <= x; j++) {
      cin >> y;
      a[i][y] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      bitset<2010> no = a[i] & a[j];
      if (no.count() == 2) {
        x = 0, y = 0;
        for (int k = 1; k <= n; k++) {
          if (no[k]) {
            if (x == 0)
              x = k;
            else
              y = k;
          }
        }
        if (!c[x][y]) {
          m++;
          c[x][y] = c[y][x] = c[x][x] = c[y][y] = 1;
          d[x]++;
          d[y]++;
          qu[x] = qu[y] = 1;
        }
      }
    }
  }
  if (m == 0 || n == 2) {
    for (int i = 2; i <= n; i++) cout << 1 << ' ' << i << endl;
    return 0;
  }
  if (m == 1) {
    cout << x << ' ' << y << endl;
    for (int i = 1; i <= n; i++) {
      if (a[i].count() != n) {
        for (int j = 1; j <= n; j++) {
          if (j != x && j != y) {
            if (a[i][j])
              cout << j << ' ' << x << endl;
            else
              cout << j << ' ' << y << endl;
          }
        }
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (c[i][j]) cout << i << ' ' << j << endl;
  for (int i = 1; i <= n; i++) {
    if ((a[i] & an).count() == 0) {
      for (int j = 1; j <= n; j++) {
        if (d[j] == 1 && (a[i] & qu) == c[j]) {
          for (int k = 1; k <= n; k++) {
            if (d[k] == 0 && a[i][k]) {
              an[k] = 1;
              cout << j << ' ' << k << endl;
            }
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if ((a[i] & an).count() == 0) {
      for (int j = 1; j <= n; j++) {
        if ((a[i] & qu) == c[j]) {
          for (int k = 1; k <= n; k++) {
            if (d[k] == 0 && a[i][k]) {
              an[k] = 1;
              cout << j << ' ' << k << endl;
            }
          }
        }
      }
    }
  }
  return 0;
}
