Problem: We guessed a permutation p consisting of n integers. The permutation of length n is the array of length n where each element from 1 to n appears exactly once. This permutation is a secret for you.

For each position r from 2 to n we chose some other index l (l < r) and gave you the segment p_l, p_{l + 1}, ..., p_r in sorted order (i.e. we rearranged the elements of this segment in a way that the elements of this segment are sorted). Thus, you are given exactly n-1 segments of the initial permutation but elements inside each segment are sorted. The segments are given to you in random order.

For example, if the secret permutation is p=[3, 1, 4, 6, 2, 5] then the possible given set of segments can be:

  * [2, 5, 6] 
  * [4, 6] 
  * [1, 3, 4] 
  * [1, 3] 
  * [1, 2, 4, 6] 



Your task is to find any suitable permutation (i.e. any permutation corresponding to the given input data). It is guaranteed that the input data corresponds to some permutation (i.e. such permutation exists).

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

The first line of the test case contains one integer n (2 ≤ n ≤ 200) — the length of the permutation.

The next n-1 lines describe given segments.

The i-th line contains the description of the i-th segment. The line starts with the integer k_i (2 ≤ k_i ≤ n) — the length of the i-th segment. Then k_i integers follow. All integers in a line are distinct, sorted in ascending order, between 1 and n, inclusive.

It is guaranteed that the required p exists for each test case.

It is also guaranteed that the sum of n over all test cases does not exceed 200 (∑ n ≤ 200).

Output

For each test case, print the answer: n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, all p_i should be distinct) — any suitable permutation (i.e. any permutation corresponding to the test case input).

Example

Input


5
6
3 2 5 6
2 4 6
3 1 3 4
2 1 3
4 1 2 4 6
5
2 2 3
2 1 2
2 1 4
2 4 5
7
3 1 2 6
4 1 3 5 6
2 1 2
3 4 5 7
6 1 2 3 4 5 6
3 1 3 6
2
2 1 2
5
2 2 5
3 2 3 5
4 2 3 4 5
5 1 2 3 4 5


Output


3 1 4 6 2 5 
3 2 1 4 5 
2 1 6 3 5 4 7 
1 2 
2 5 3 4 1 

Solution (in JAVA):

Solution:
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;


/* Name of the class has to be "Main" only if the class is public. */
public class codechef
{
         static class Input {
        private StringTokenizer tokenizer = null;
        private BufferedReader reader;
 
        public Input(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }
 
        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(nextLine());
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
 
        public int[] nextIntArray(int n, int add) {
            int[] result = new int[n];
            for (int i = 0; i < n; i++) {
                result[i] = nextInt() + add;
            }
            return result;
        }
 
        public long[] nextLongArray(int n, long add) {
            long[] result = new long[n];
            for (int i = 0; i < n; i++) {
                result[i] = nextLong() + add;
            }
            return result;
        }
 
        public int[] nextIntArray(int n) {
            return nextIntArray(n, 0);
        }
 
    }
    
    static boolean verify(int ans[],HashSet<Integer> hs[])
    {
        int n=ans.length;
        for(int i=0;i<n-1;i++)
        {
            boolean start=false;
            int cnt=0;
            for(int j=0;j<n;j++)
            {
                if(hs[i].contains(ans[j]))
                { 
                    start=true;
                    cnt++;
                }
                else
                {
                    if(start)
                    if(cnt!=hs[i].size())
                    return false;
                    else
                    break;
                }
            }
        }
        return true;
    }


	public static void main (String[] args) throws java.lang.Exception
	{
		Input s=new Input(System.in);
		int t=s.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		
		while(t-->0)
		{
            int n=s.nextInt();
            HashSet<Integer> segs[]=new HashSet[n-1];
            for(int i=0;i<n-1;i++)
            {
                int al=s.nextInt();
                segs[i]=new HashSet<>();
                for(int j=0;j<al;j++)
                segs[i].add(s.nextInt());
            }
            for(int l=1;l<=n;l++)
            {
                //out.println("l "+l);
                int ans[]=new int[n];
                ans[0]=l; 
               HashSet<Integer> tsegs[]=new HashSet[n-1];
               int ss[]=new int[n-1];
               for(int i=0;i<n-1;i++)
               {
                   tsegs[i]=new HashSet<>();
                   for(Integer am:segs[i])
                   tsegs[i].add(am);
                   ss[i]=tsegs[i].size();
               }
               boolean ok=true;
               int last=l;
               boolean used[]=new boolean[n+1];
               used[l]=true;
               
               for(int j=0;j<n-1;j++)
               {
                  if(tsegs[j].contains(l))
                  {tsegs[j].remove(l);
                   ss[j]--; 
                  }
               }
               int cur=1;
               for(;cur<n;cur++)
               {
                        ok=false;
                        for(int j=0;j<n-1;j++)
                        {
                           if(ss[j]==1) 
                           {
                               ok=true;
                               //out.println("here"+tsegs[j]);
                               for(Integer am:tsegs[j])
                               {
                                   last=am;
                                   ok=true;
                               }
                               break;
                           }
                        }

                        if(ok)
                        {   ans[cur]=last;
                            used[last]=true;
                            for(int j=0;j<n-1;j++)
                            {
                                if(tsegs[j].contains(last))
                                {tsegs[j].remove(last);
                                 ss[j]--;   
                                }
                            }
                        }
                        else
                        break;


                    
               }

               if(cur==n && verify(ans,segs))
               {
                   for(int i=0;i<n;i++)
                    out.print(ans[i]+" ");
                    out.println();
                    break;
               }

               
            }


        }
        out.flush();



	}
}