#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n + 1);
    vector<int> segsz(n - 1);
    vector<vector<int> > present(n - 1, vector<int>(n + 1, 0));
    for (int i = 0; i < n - 1; i++) {
      int k;
      cin >> k;
      segsz[i] = k;
      for (int j = 0; j < k; j++) {
        int num;
        cin >> num;
        present[i][num] = 1;
      }
    }
    int possible = 1;
    for (int i = 1; i <= n; i++) {
      arr[1] = i;
      possible = 1;
      vector<int> tempsz = segsz;
      vector<vector<int> > tempPresent = present;
      for (int j = 2; j <= n; j++) {
        for (int idx = 0; idx < n - 1; idx++)
          if (tempPresent[idx][arr[j - 1]])
            tempPresent[idx][arr[j - 1]] = 0, tempsz[idx]--;
        vector<int> vec;
        for (int l = 0; l < n - 1; l++)
          if (tempsz[l] == 1) vec.push_back(l);
        if (vec.size() != 1) {
          possible = 0;
          break;
        }
        int segindex = vec[0];
        for (int idxx = 1; idxx <= n; idxx++) {
          if (tempPresent[segindex][idxx]) {
            arr[j] = idxx;
            break;
          }
        }
      }
      if (possible == 0) continue;
      vector<int> idxval(n + 1);
      for (int j = 1; j <= n; j++) idxval[arr[j]] = j;
      set<int> s;
      for (int j = 0; j < n - 1; j++) {
        std::vector<int> vi;
        for (int l = 1; l <= n; l++)
          if (present[j][l]) vi.push_back(idxval[l]);
        sort(vi.begin(), vi.end());
        for (int l = 1; l < vi.size(); l++) {
          if (vi[l] != vi[l - 1] + 1) {
            possible = 0;
            break;
          }
        }
        if (possible == 1) {
          s.insert(vi.back());
        }
      }
      if (s.size() == n - 1 && possible == 1) {
        for (int j = 1; j <= n; j++) cout << arr[j] << " ";
        cout << "\n";
        break;
      }
    }
  }
}
