#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vector<set<int>> st;
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
      int k;
      cin >> k;
      set<int> cur;
      for (int i = 0; i < k; i++) {
        int a;
        cin >> a;
        cur.insert(a);
      }
      st.push_back(cur);
    }
    for (int i = 1; i <= n; i++) {
      vector<int> ans;
      bool ok = true;
      vector<set<int>> cur = st;
      for (auto &it : cur) {
        if (it.count(i)) it.erase(i);
      }
      ans.push_back(i);
      for (int j = 1; j < n; j++) {
        int cnt = 0;
        int next = -1;
        for (auto &it : cur) {
          if (it.size() == 1) cnt++, next = *it.begin();
        }
        if (cnt != 1) {
          ok = false;
          break;
        }
        for (auto &it : cur) {
          if (it.count(next)) it.erase(next);
        }
        ans.push_back(next);
      }
      if (ok) {
        set<set<int>> all(st.begin(), st.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) ok = false;
        }
      }
      if (ok) {
        for (auto it : ans) cout << it << " ";
        cout << endl;
        break;
      }
    }
  }
}
