#include <bits/stdc++.h>
using namespace std;
vector<int> e[1010];
vector<int> g[1010][1010];
vector<pair<int, int> > ans;
queue<pair<int, int> > q;
int n, m, flag, cnt[1010], pos[1010][1010], v[1010], tot, col, nam[1010];
bool dfs(int x, int dad) {
  if (v[x]) return 0;
  ans.push_back(make_pair(x, dad));
  tot++;
  v[x] = col;
  for (int i = 0; i < e[x].size(); i++)
    if (e[x][i] != dad && !dfs(e[x][i], x)) return 0;
  return 1;
}
bool split(int x) {
  int i, j, k;
  for (i = 1; i <= n; i++) v[i] = 0;
  if (cnt[x] != e[x].size()) return 0;
  for (col = 1; col <= e[x].size(); col++)
    if (!dfs(e[x][col - 1], x)) return 0;
  for (i = 1; i <= cnt[x]; i++) nam[i] = 0;
  for (i = 1; i <= n; i++)
    if (i != n) {
      if (!nam[pos[i][x]]) nam[pos[i][x]] = v[x];
      if (nam[pos[i][x]] != v[x]) return 0;
    }
  return 1;
}
void work() {
  tot = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (g[i][pos[j][i]].size() + g[j][pos[i][j]].size() == n) {
        e[i].push_back(j);
        e[j].push_back(i);
      }
  for (int i = 1; i <= n; i++) {
    flag &= split(i);
    if (!flag) return;
  }
}
int main() {
  char ch;
  int i, j, k, t, x, y;
  flag = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    t = cnt[i] = 0;
    while (t < n - 1) {
      ++cnt[i];
      if (t) ch = getchar();
      scanf("%d", &k);
      ch = getchar();
      t += k;
      while (k--) {
        scanf("%d", &x);
        g[i][cnt[i]].push_back(x);
        pos[x][i] = cnt[i];
        if (k) ch = getchar();
      }
    }
  }
  work();
  if (!flag) {
    puts("-1");
    return 0;
  }
  printf("%d\n", n - 1);
  for (int i = 0; i < n - 1; i++)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
