#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
bitset<N> b[N];
vector<pair<int, int> > e[N];
int f[N], n, x, y;
int find(int x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (int j = 1; j <= x; j++) {
      scanf("%d", &y);
      b[y][i] = 1;
    }
  }
  for (int i = 1; i <= 2 * n; i++) f[i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      int cnt = (b[i] & b[j]).count();
      if (cnt == 1) {
        f[find(i)] = find(j);
        f[find(i + n)] = find(j + n);
      } else if (cnt == 2 && n >= 3) {
        f[find(i)] = find(j + n);
        f[find(i + n)] = find(j);
      } else
        e[cnt].push_back(make_pair(i, j));
    }
  if ((int)e[n].size() == n * (n - 1) / 2) {
    for (int i = 2; i <= n; i++) printf("1 %d\n", i);
    return 0;
  }
  if (e[n].size() == 1) {
    int x = 0, y = 0;
    for (int i = 1; i <= n; i++)
      if (b[i].count() == n) {
        if (x)
          y = i;
        else
          x = i;
      }
    printf("%d %d\n", x, y);
    for (int i = 1; i <= n; i++)
      if (i != x && i != y) {
        if (find(i) == find(x)) {
          printf("%d %d\n", i, y);
          f[find(i)] = find(y + n);
          f[find(y + n)] = find(i);
        } else {
          printf("%d %d\n", i, x);
          f[find(i)] = find(x + n);
          f[find(x)] = find(i + n);
        }
      }
    return 0;
  }
  for (int i = n; i; i--)
    for (int j = 0; j < (int)e[i].size(); j++) {
      int x = e[i][j].first, y = e[i][j].second;
      if (find(x) == find(y)) continue;
      printf("%d %d\n", x, y);
      f[find(x)] = find(y + n);
      f[find(y)] = find(x + n);
    }
  return 0;
}
