#include <bits/stdc++.h>
using namespace std;
const int N = 510;
vector<int> arr[N];
int n, k;
bool done[N], has[N][N];
int cur[N], mn[N];
void Print(vector<int> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i) putchar(' ');
    printf("%d", v[i]);
  }
  puts("");
}
bool check(vector<int> &v) {
  for (int i = 1; i <= n; i++) done[i] = false;
  for (int i = 0; i < n - 1; i++) cur[i] = 0, mn[i] = 1000000010;
  done[v[0]] = true;
  done[v[1]] = true;
  for (int j = 0; j < n - 1; j++) {
    if (has[j][v[0]]) cur[j]++, mn[j] = 0;
    if (has[j][v[1]]) {
      cur[j]++;
      mn[j] = min(mn[j], 1);
    }
  }
  while ((int)v.size() < n) {
    bool found = false;
    for (int i = 0; i < n - 1; i++) {
      if (cur[i] != (int)arr[i].size() - 1) continue;
      int x = (int)v.size();
      if ((x - mn[i] + 1) != (int)arr[i].size()) return false;
      for (int j = 0; j < (int)arr[i].size(); j++) {
        if (!done[arr[i][j]]) x = arr[i][j];
      }
      done[x] = true;
      found = true;
      for (int j = 0; j < n - 1; j++) {
        if (has[j][x]) {
          cur[j]++;
          mn[j] = min(mn[j], (int)v.size());
        }
      }
      v.push_back(x);
      break;
    }
    if (!found) return false;
  }
  return true;
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &k);
    arr[i].clear();
    arr[i].resize(k);
    for (int j = 1; j <= n; j++) has[i][j] = false;
    for (int j = 0; j < k; j++) {
      scanf("%d", &arr[i][j]);
      has[i][arr[i][j]] = true;
    }
  }
  vector<int> v;
  for (int i = 0; i < n - 1; i++) {
    if ((int)arr[i].size() != 2) continue;
    v.clear();
    v.push_back(arr[i][0]);
    v.push_back(arr[i][1]);
    if (check(v)) {
      Print(v);
      return;
    }
    v.clear();
    v.push_back(arr[i][1]);
    v.push_back(arr[i][0]);
    if (check(v)) {
      Print(v);
      return;
    }
  }
  assert(false);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
