#include <bits/stdc++.h>
using namespace std;
void print(vector<set<int> > x) {
  for (int i = 0; i < x.size(); i++) {
    set<int>::iterator it;
    for (it = x[i].begin(); it != x[i].end(); it++) {
      cout << *it << ' ';
    }
    cout << endl;
  }
  cout << endl;
}
int main(void) {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<set<int> > segs;
    for (int i = 0; i < n - 1; i++) {
      set<int> seg;
      int k;
      cin >> k;
      for (int j = 0; j < k; j++) {
        int p;
        cin >> p;
        seg.insert(p);
      }
      segs.push_back(seg);
    }
    for (int fir = 1; fir <= n; fir++) {
      vector<int> ans;
      bool flag = true;
      vector<set<int> > cur = segs;
      for (int i = 0; i < cur.size(); i++) {
        set<int>& seg = cur[i];
        if (seg.count(fir) != 0) seg.erase(fir);
      }
      ans.push_back(fir);
      for (int i = 1; i < n; i++) {
        int cnt = 0;
        int nxt = -1;
        for (int j = 0; j < cur.size(); j++) {
          set<int> seg = cur[j];
          if (seg.size() == 1) {
            cnt++;
            nxt = *seg.begin();
          }
        }
        if (cnt != 1) {
          flag = false;
          break;
        }
        for (int j = 0; j < cur.size(); j++) {
          set<int>& seg = cur[j];
          if (seg.count(nxt) != 0) seg.erase(nxt);
        }
        ans.push_back(nxt);
      }
      if (flag) {
        set<set<int> > all(segs.begin(), segs.end());
        for (int i = 1; i < n; ++i) {
          set<int> seg;
          seg.insert(ans[i]);
          bool found = false;
          for (int j = i - 1; j >= 0; --j) {
            seg.insert(ans[j]);
            if (all.count(seg)) {
              found = true;
              all.erase(seg);
              break;
            }
          }
          if (!found) {
            flag = false;
            break;
          }
        }
      }
      if (flag) {
        vector<int>::iterator vit;
        for (vit = ans.begin(); vit != ans.end(); vit++) {
          cout << *vit << " ";
        }
        cout << endl;
        break;
      }
    }
  }
  return 0;
}
