#include "testlib.h"

const int maxn = 1000;
const int maxc = 1000;
const int maxm = 10000;
const int maxk = 10;

int main() {
  registerValidation();
  int n = inf.readInt(1, maxn, "n");
  inf.readEoln();
  int sum_k = 0;
  for (int i = 0; i < n; i++) {
    int k = inf.readInt(1, maxm, "k");
    sum_k += k;
    ensuref(sum_k <= maxm, "total amount of edges too large");
    int a[k];
    for (int j = 0; j < k; j++) {
      inf.readSpace();
      a[j] = inf.readInt(1, maxc);
      inf.readSpace();
      inf.readInt(1, maxk);
    }
    std::sort(a, a + k);
    for (int j = 1; j < k; j++)
      ensuref(a[j - 1] != a[j], "sportsman #%d tries to participate in #%d twice", i + 1, a[j]);
    inf.readEoln();
  }
  inf.readEof();
}

