#include <bits/stdc++.h>
using namespace std;
int t, n, x;
int cnt[310], ans[310], to[310];
vector<int> p[310];
bool vis_se[310], vis_num[310], vis[310];
bool dfs(int c) {
  if (c == n - 1) {
    for (int i = 1; i <= n; i++)
      if (vis[i]) {
        ans[1] = i;
        to[i] = 1;
        break;
      }
    for (int i = 1; i < n; i++) {
      int minn = n + 1, maxn = 0;
      for (auto j : p[i]) {
        maxn = max(maxn, to[j]);
        minn = min(minn, to[j]);
      }
      if (maxn - minn != cnt[i] - 1) {
        to[ans[1]] = -n;
        ans[1] = 0;
        return false;
      }
    }
    return true;
  }
  int tmp[310];
  bool tmpvis[310];
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i < n; i++) {
    if (!vis_se[i]) continue;
    for (auto j : p[i]) tmp[j]++;
  }
  for (int i = 1; i < n; i++) {
    if (!vis_se[i]) continue;
    for (auto j : p[i])
      if (tmp[j] == 1 && vis_num[j]) {
        ans[n - c] = j;
        vis_se[i] = vis[j] = false;
        to[j] = n - c;
        for (int k = 1; k <= n; k++) {
          tmpvis[k] = vis_num[k];
          vis_num[k] = 0;
        }
        for (auto k : p[i]) vis_num[k] = 1;
        bool f = dfs(c + 1);
        if (f) return true;
        vis_se[i] = vis[j] = true;
        to[j] = -n;
        ans[n - c] = 0;
        for (int k = 1; k <= n; k++) vis_num[k] = tmpvis[k];
      }
  }
  return false;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
      p[i].clear();
      scanf("%d", &cnt[i]);
      for (int j = 1; j <= cnt[i]; j++) scanf("%d", &x), p[i].push_back(x);
    }
    for (int i = 1; i <= n; i++) {
      vis_se[i] = vis_num[i] = vis[i] = 1;
      to[i] = -n;
    }
    bool f = dfs(0);
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
