#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 1111;
int n, murmur, cnt, p[N * N], rebros, ok[N], timer, cur2;
bool z[N][N];
vector<int> v, g[N * N], u[N], t[N];
vector<pair<int, int> > my_sort;
char second[10 * N];
bool used[N + N];
void dfs(int Real_Betis) {
  ok[Real_Betis] = timer;
  t[cur2].push_back(Real_Betis);
  for (auto j : u[Real_Betis])
    if (ok[j] != timer) dfs(j);
}
bool check() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (z[i][j]) u[i].push_back(j);
  int cur = 1;
  for (int i = 1; i <= n; ++i) {
    cur2 = 0;
    timer++;
    ok[i] = timer;
    for (auto j : u[i]) {
      ++cur2;
      t[cur2].clear();
      dfs(j);
      sort(t[cur2].begin(), t[cur2].end());
    }
    sort(t + 1, t + cur2 + 1);
    for (int j = 1; j <= cur2; ++j) {
      if (t[j] != g[cur]) return 0;
      cur++;
    }
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", second + 1);
    int m = strlen(second + 1);
    int last = cnt;
    for (int j = 1; j <= m; j++) {
      int num = 0;
      int k = j - 1;
      while (k < m && '0' <= second[k + 1] && second[k + 1] <= '9') {
        k++;
        num = num * 10 + second[k] - '0';
      }
      k++;
      v.clear();
      while (1) {
        int ver = 0;
        while (k < m && '0' <= second[k + 1] && second[k + 1] <= '9') {
          k++;
          ver = ver * 10 + second[k] - '0';
        }
        v.push_back(ver);
        if (k == m || second[k + 1] == '-') break;
        k++;
      }
      j = k + 1;
      sort(v.begin(), v.end());
      g[++cnt] = v;
      p[cnt] = i;
      if (cnt > n + n - 2) {
        printf("-1");
        return 0;
      }
    }
    sort(g + last + 1, g + cnt + 1);
    for (int j = last + 1; j <= cnt; ++j)
      my_sort.push_back(make_pair(g[j].size(), j));
  }
  sort(my_sort.begin(), my_sort.end());
  for (int i = 0; i < cnt; ++i) {
    int num = my_sort[i].second;
    int kolvo = 0, rt = 0;
    for (int j = 0; j < (int)g[num].size(); ++j) {
      if (!used[g[num][j]]) {
        rt = g[num][j];
        ++kolvo;
      }
    }
    if (kolvo == 1) {
      used[rt] = 1;
      z[rt][p[num]] = z[p[num]][rt] = 1;
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (z[i][j]) rebros++;
  if (rebros == n + n - 2 && check()) {
    printf("%d", n - 1);
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j < i; ++j)
        if (z[i][j]) printf("\n%d %d", i, j);
  } else
    cout << -1;
  return 0;
}
