#include <bits/stdc++.h>
using namespace std;
int n, f, i, j, k, d, b[1008], a[1008][1008], c[1008][1008];
vector<vector<int> > u[1008];
vector<int> v, w[1008];
void dfs(int p, int q) {
  if (!b[p])
    for (int r = w[++d, b[p] = p].size(); r--;
         w[p][r] == q ? (void)0 : dfs(w[p][r], p))
      ;
}
int main() {
  for (scanf("%d", &n); i++ < n;)
    for (f = n - 1; f; u[i].push_back(v), v.clear())
      for (scanf("%*c%d", &k); k--;
           --f, scanf("%*c%d", &j), v.push_back(j), a[i][j] = u[i].size())
        ;
  for (i = 0; i++ < n;)
    for (j = i; j++ < n;
         u[i][a[i][j]].size() + u[j][a[j][i]].size() == n
             ? (w[i].push_back(j), w[j].push_back(i), c[i][j] = c[j][i] = 1)
             : 0)
      ;
  for (f = 1, i = 0; i++ < n && f;)
    for (j = u[i].size(); j-- && f; f &= !d) {
      for (k = u[i][j].size(); k--;
           c[i][u[i][j][k]] ? (dfs(u[i][j][k], i), k = 0) : 0)
        ;
      for (k = u[i][j].size(); k-- && f;
           --d, f &= !!b[u[i][j][k]], b[u[i][j][k]] = 0)
        ;
    }
  if (f)
    for (printf("%d\n", n - 1), i = 0; i++ < n;)
      for (j = w[i].size(); j--;
           i < w[i][j] ? printf("%d %d\n", i, w[i][j]) : 0)
        ;
  else
    printf("-1\n");
  exit(0);
}
