#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
struct mb {
  bitset<1003> bs;
};
char in[1005 * 1005];
int len;
bool isnum(char x) { return '0' <= x && x <= '9'; }
int rd(int &i) {
  int ret = 0;
  while (i < len && isnum(in[i])) {
    ret = ret * 10 + (in[i] - '0');
    i++;
  }
  return ret;
}
vector<mb> vp;
int A[1005][1005];
vector<int> mp[1005];
bitset<1003> dp[1005];
void dfs(int x, int pa) {
  dp[x][x] = 1;
  for (int c : mp[x])
    if (c != pa) {
      dfs(c, x);
      if ((vp[A[x][c]].bs ^ dp[c]).any()) {
        et();
      }
      dp[x] |= dp[c];
    }
}
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%s", in);
    len = (int)strlen(in);
    int pos = 0;
    while (pos < len) {
      int sz = rd(pos);
      assert(in[pos] == ':');
      pos++;
      mb nb;
      int id = (int)vp.size();
      for (int(j) = 0; (j) < (int)(sz); (j)++) {
        int num = rd(pos);
        nb.bs[num] = 1;
        A[i][num] = id;
        pos++;
      }
      vp.push_back(nb);
    }
  }
  vector<pair<int, int> > es;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    for (int j = i + 1; j <= n; j++) {
      int x = A[i][j], y = A[j][i];
      if ((vp[x].bs ^ vp[y].bs).count() == n) {
        es.push_back({i, j});
        mp[i].push_back(j);
        mp[j].push_back(i);
      }
    }
  if (es.size() != n - 1) et();
  dfs(1, 0);
  printf("%d\n", n - 1);
  for (auto p : es) printf("%d %d\n", p.first, p.second);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
