#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<int> sz(n - 1), in[n], lst[n];
    for (int s, i = 0; i < n - 1; i++) {
      scanf("%d", &s), sz[i] = s;
      for (int a, j = 0; j < s; j++) {
        scanf("%d", &a);
        in[a - 1].push_back(i);
        lst[i].push_back(a - 1);
      }
    }
    for (int s = 0; s < n; s++) {
      vector<int> szx = sz, ans{s}, with(n);
      while (true) {
        int nw = -69;
        for (int i : in[ans.back()])
          if (--szx[i] == 1 && ~nw) nw = (nw < 0 ? i : -1);
        if (nw < 0) break;
        int added = 0;
        for (int i = (int)ans.size() - sz[nw] + 1; i < ans.size(); i++)
          with[ans[i]] = 1;
        for (int j : lst[nw])
          if (!with[j]) ans.push_back(j), added++;
        for (int i = (int)ans.size() - sz[nw]; i < ans.size(); i++)
          with[ans[i]] = 0;
        if (added > 1) {
          ans.clear();
          break;
        }
      }
      if (ans.size() == n) {
        for (int& a : ans) printf("%d ", a + 1);
        printf("\n");
        break;
      }
    }
  }
}
