#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int Get_Num(char *s, int &i) {
  int res = 0;
  while ('0' > s[i] || s[i] > '9') i++;
  while ('0' <= s[i] && s[i] <= '9') res = res * 10 + s[i] - '0', i++;
  return res;
}
int head[maxn], nxt[maxn << 1], E[maxn << 1], Ecnt;
void Add_Edge(int x, int y) {
  nxt[++Ecnt] = head[x];
  head[x] = Ecnt;
  E[Ecnt] = y;
  nxt[++Ecnt] = head[y];
  head[y] = Ecnt;
  E[Ecnt] = x;
}
int mp[maxn][maxn];
int cnt[maxn][maxn];
int vis[maxn];
int num[maxn];
int n;
void Process(int x, char *s) {
  int len = strlen(s), i = 0;
  while (i < len) {
    int numt = Get_Num(s, i);
    cnt[x][num[x]++] = numt;
    for (int j = 0; j < numt; j++) {
      int numx = Get_Num(s, i);
      mp[x][numx] = num[x] - 1;
    }
  }
}
bool DFS(int x, int father = 0) {
  vis[x] = 1;
  for (int i = head[x]; i; i = nxt[i])
    if (E[i] != father) {
      if (vis[E[i]])
        return false;
      else if (!DFS(E[i], x))
        return false;
    }
  return true;
}
bool DFS2(int x, int father, int s, int s2) {
  if (mp[s][x] != mp[s][s2]) return false;
  for (int i = head[x]; i; i = nxt[i])
    if (E[i] != father)
      if (!DFS2(E[i], x, s, s2)) return false;
  return true;
}
void Solve() {
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (cnt[i][mp[i][j]] + cnt[j][mp[j][i]] == n) {
        Add_Edge(i, j);
        if (Ecnt == n * 2) {
          printf("-1\n");
          return;
        }
      }
  if (!DFS(1)) {
    printf("-1\n");
    return;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      printf("-1\n");
      return;
    }
  for (int i = 1; i <= n; i++)
    for (int j = head[i]; j; j = nxt[j])
      if (!DFS2(E[j], i, i, E[j])) {
        printf("-1\n");
        return;
      }
  printf("%d\n", n - 1);
  for (int i = 1; i <= n; i++)
    for (int j = head[i]; j; j = nxt[j])
      if (i < E[j]) printf("%d %d\n", i, E[j]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    static char s[maxn << 2];
    scanf("%s", s);
    Process(i, s);
  }
  Solve();
  return 0;
}
