Problem: We are committed to the well being of all participants. Therefore, instead of the problem, we suggest you enjoy a piece of cake.

Uh oh. Somebody cut the cake. We told them to wait for you, but they did it anyway. There is still some left, though, if you hurry back. Of course, before you taste the cake, you thought about how the cake was cut.

It is known that the cake was originally a regular n-sided polygon, each vertex of which had a unique number from 1 to n. The vertices were numbered in random order.

Each piece of the cake is a triangle. The cake was cut into n - 2 pieces as follows: each time one cut was made with a knife (from one vertex to another) such that exactly one triangular piece was separated from the current cake, and the rest continued to be a convex polygon. In other words, each time three consecutive vertices of the polygon were selected and the corresponding triangle was cut off.

A possible process of cutting the cake is presented in the picture below.

<image> Example of 6-sided cake slicing.

You are given a set of n-2 triangular pieces in random order. The vertices of each piece are given in random order — clockwise or counterclockwise. Each piece is defined by three numbers — the numbers of the corresponding n-sided cake vertices.

For example, for the situation in the picture above, you could be given a set of pieces: [3, 6, 5], [5, 2, 4], [5, 4, 6], [6, 3, 1].

You are interested in two questions.

  * What was the enumeration of the n-sided cake vertices? 
  * In what order were the pieces cut? 



Formally, you have to find two permutations p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) and q_1, q_2, ..., q_{n - 2} (1 ≤ q_i ≤ n - 2) such that if the cake vertices are numbered with the numbers p_1, p_2, ..., p_n in order clockwise or counterclockwise, then when cutting pieces of the cake in the order q_1, q_2, ..., q_{n - 2} always cuts off a triangular piece so that the remaining part forms one convex polygon.

For example, in the picture above the answer permutations could be: p=[2, 4, 6, 1, 3, 5] (or any of its cyclic shifts, or its reversal and after that any cyclic shift) and q=[2, 4, 1, 3].

Write a program that, based on the given triangular pieces, finds any suitable permutations p and q.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then there are t independent sets of input data.

The first line of each set consists of a single integer n (3 ≤ n ≤ 10^5) — the number of vertices in the cake.

The following n - 2 lines describe the numbers of the pieces vertices: each line consists of three different integers a, b, c (1 ≤ a, b, c ≤ n) — the numbers of the pieces vertices of cake given in random order. The pieces are given in random order.

It is guaranteed that the answer to each of the tests exists. It is also guaranteed that the sum of n for all test cases does not exceed 10^5.

Output

Print 2t lines — answers to given t test cases in the order in which they are written in the input. Each answer should consist of 2 lines.

In the first line of an answer on a test case print n distinct numbers p_1, p_2, ..., p_n(1 ≤ p_i ≤ n) — the numbers of the cake vertices in clockwise or counterclockwise order.

In the second line of an answer on a test case print n - 2 distinct numbers q_1, q_2, ..., q_{n - 2}(1 ≤ q_i ≤ n - 2) — the order of cutting pieces of the cake. The number of a piece of the cake corresponds to its number in the input.

If there are several answers, print any. It is guaranteed that the answer to each of the tests exists.

Example

Input


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


Output


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

Solution (in JAVA):

Solution:
import java.util.*;



import java.io.*;
import java.text.*;

public class E1282 {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			TreeSet<Edge>[] adjList = new TreeSet[n - 2];
			for (int i = 0; i < adjList.length; i++) {
				adjList[i] = new TreeSet<Edge>();
			}
			TreeMap<Pair, Integer> tm = new TreeMap<Pair, Integer>();
			Node[] pol = new Node[n + 1];
			for (int i = 1; i < pol.length; i++) {
				pol[i] = new Node(null, i);
			}
			int[] aa = new int[n - 2];
			int[] bb = new int[n - 2];
			int[] cc = new int[n - 2];

			for (int i = 0; i < n - 2; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				aa[i] = a;
				bb[i] = b;
				cc[i] = c;
				Pair ab = new Pair(a, b);
				Pair bc = new Pair(b, c);
				Pair ac = new Pair(a, c);
				if (tm.containsKey(ab)) {
					int x = tm.get(ab);
					int h = -1;
					if (aa[x] != a && aa[x] != b) {
						h = aa[x];
					}
					if (bb[x] != a && bb[x] != b) {
						h = bb[x];
					}
					if (cc[x] != a && cc[x] != b) {
						h = cc[x];
					}

					adjList[x].add(new Edge(i, a, b, c));
					adjList[i].add(new Edge(x, a, b, h));
				}
				if (tm.containsKey(bc)) {
					int x = tm.get(bc);
					int h = -1;
					if (aa[x] != b && aa[x] != c) {
						h = aa[x];
					}
					if (bb[x] != b && bb[x] != c) {
						h = bb[x];
					}
					if (cc[x] != b && cc[x] != c) {
						h = cc[x];
					}
					adjList[x].add(new Edge(i, b, c, a));
					adjList[i].add(new Edge(x, b, c, h));
				}
				if (tm.containsKey(ac)) {
					int x = tm.get(ac);
					int h = -1;
					if (aa[x] != a && aa[x] != c) {
						h = aa[x];
					}
					if (bb[x] != a && bb[x] != c) {
						h = bb[x];
					}
					if (cc[x] != a && cc[x] != c) {
						h = cc[x];
					}
					adjList[x].add(new Edge(i, a, c, b));
					adjList[i].add(new Edge(x, a, c, h));
				}
				tm.put(ab, i);
				tm.put(bc, i);
				tm.put(ac, i);
			}
//			pw.println(Arrays.deepToString(adjList));
//			pw.println(Arrays.deepToString(adjList));
			ArrayList<Integer> seq = new ArrayList<Integer>();
			Queue<Integer> q = new LinkedList<Integer>();
			int[] numEdges = new int[n - 2];
			for (int i = 0; i < numEdges.length; i++) {
				numEdges[i] = adjList[i].size();
				if (numEdges[i] == 1)
					q.add(i);
			}

			boolean[] taken = new boolean[n - 2];
//			pw.println(q);
			while (!q.isEmpty()) {
				int cur = q.poll();
				seq.add(cur);
				taken[cur] = true;

				for (Edge e : adjList[cur]) {
					numEdges[e.v]--;
					if (numEdges[e.v] == 1) {
						q.add(e.v);

					}

				}
			}
//			pw.println(seq);
			StringBuilder sb = new StringBuilder();

			if (seq.isEmpty())
				seq.add(0);
			int last = seq.get(seq.size() - 1);
			pol[aa[last]].x = pol[bb[last]];
			pol[bb[last]].x = pol[cc[last]];
			pol[cc[last]].x = pol[aa[last]];
			q = new LinkedList<Integer>();
			q.add(last);
			boolean[] vis = new boolean[n - 2];
			while (!q.isEmpty()) {
				int cur = q.poll();
				vis[cur] = true;
				for (Edge e : adjList[cur]) {
					if (!vis[e.v]) {
//						pw.println(e.a + " " + e.b + " " + e.c);
//						pw.println(Arrays.toString(pol));
						merge(pol[e.a], pol[e.b], pol[e.c]);
//						pw.println(Arrays.toString(pol));
						q.add(e.v);
						vis[e.v] = true;
					}

				}
			}
			int cur = 1;
			while (true) {
				pw.print(cur + " ");
				cur = pol[cur].x.data;
				if (cur == 1)
					break;
			}
			pw.println();
//			pw.println(Arrays.toString(pol));
			for (int x : seq) {
				pw.print(x + 1 + " ");
			}
			pw.println();

		}
		pw.close();
	}

	static void merge(Node a, Node b, Node c) {
		if (a.x == b) {
			a.x = c;
			c.x = b;
		} else {
			b.x = c;
			c.x = a;
		}
	}

	static class Node {
		Node x;
		int data;

		public Node(Node a, int y) {
			data = y;
			x = a;
		}

		public String toString() {
			return data + "->" + (x == null ? null : x.data);
		}
	}

	static class Edge implements Comparable<Edge> {
		int v, a, b, c;

		public Edge(int y, int z, int w, int x) {

			v = y;
			a = Math.min(z, w);
			b = Math.max(z, w);
			c = x;
		}

		public int compareTo(Edge e) {
			return e.v - v;
		}

		public String toString() {
			return v + " " + a + " " + b + " " + c;
		}
	}

	static class Pair implements Comparable<Pair> {
		int t, c;

		public Pair(int t, int c) {
			this.t = Math.min(t, c);
			this.c = Math.max(t, c);
		}

		public int compareTo(Pair p) {
			return p.t - t == 0 ? p.c - c : p.t - t;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}