// Arup Guha
// 10/6/2015
// Solution to 2003 HS Problem: Springfield Skippy and the Cymbal of Doom

// Note: It's sort of crappy I wrote this all in main. I guess I just thought of this very "linearly".

import java.util.*;

public class cymbal {

	final public static int NOEDGE = 1000000000;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process all cases.
		for (int loop=1; loop<=numCases; loop++) {

			// Set up adjacency matrix (good enough for this problem)
			int n = stdin.nextInt();
			int[][] adj = new int[n][n];
			int[][] path = new int[n][n];
			boolean[] type = new boolean[n];
			boolean[] hasIncoming = new boolean[n];
			int end = -1;

			for (int i=0; i<n; i++) {
				Arrays.fill(adj[i], NOEDGE);
				Arrays.fill(path[i], -1);
				adj[i][i] = 0;
				path[i][i] = i;
			}

			// Will store current track swtich setting.
			int[] cur = new int[n];

			// Read in edges.
			for (int i=0; i<n; i++) {
				cur[i] = stdin.nextInt()-1;
				int edges = stdin.nextInt();

				// Multiple outgoing case.
				if (edges > 1) {
					type[i] = true;
					for (int j=0; j<edges; j++) {
						int next = stdin.nextInt()-1;

						// This is a new edge, set it.
						if (adj[i][next] == NOEDGE) {
							adj[i][next] = next == cur[i] ? 0 : 1;
						}

						// Edge exists, add 1 to its cost.
						else {
							if (next != cur[i]) adj[i][next]++;
						}

						// Bookkeeping.
						path[i][next] = i;
						hasIncoming[next] = true;
					}
				}

				// Multiple incoming case.
				else if (edges == 1){

					// Outgoing edge
					int next = stdin.nextInt()-1;

					// This one's free.
					adj[i][next] = 0;
					path[i][next] = i;
					hasIncoming[next] = true;
				}

				// Where we are going to.
				else
					end = i;
			}

			// Adjust incoming edges where switch isn't set. - won't affect non-edges in a significant way.
			for (int i=0; i<n; i++) {
				if (!type[i]) {
					for (int j=0; j<n; j++) {
						if (i==j) continue;
						if (j != cur[i]) adj[j][i]++;
					}
				}
			}

			// Run Floyd-Warshall's here.
			for (int k=0; k<n; k++) {
				for (int i=0; i<n; i++) {
					for (int j=0; j<n; j++) {

						// Can't improve going via vertex k.
						if (adj[i][k] == NOEDGE || adj[k][j] == NOEDGE) continue;

						// Found a better path.
						if (adj[i][k] + adj[k][j] < adj[i][j]) {
							adj[i][j] = adj[i][k] + adj[k][j];
							path[i][j] = path[k][j];
						}
					}
				}
			}

			// Set starting node.
			int start = -1;
			for (int i=0; i<n; i++)
				if (!hasIncoming[i])
					start = i;

			// Build route backwards.
			ArrayList<Integer> myRoute = new ArrayList<Integer>();
			myRoute.add(end);
			int curNode = end;
			do {
				//System.out.println("start is "+start+" curnode is "+curNode);
				curNode = path[start][curNode];
				myRoute.add(curNode);
			} while (curNode != start);
			Collections.reverse(myRoute);

			// Case header.
			System.out.println("Track System "+loop+":");

			// Buid output from route, type and cur.
			for (int i=0; i<myRoute.size(); i++) {

				// Next node to print.
				int item = myRoute.get(i);

				// Might have to set switch beforehand.
				if (!type[item]) {
					int prev = myRoute.get(i-1);
					if (cur[item] != prev)
						System.out.print("("+(prev+1)+")");
					System.out.print(item+1);
				}

				// Might have switch after.
				else {

					// Print first.
					System.out.print(item+1);

					// See where the switch is set and where we are going.
					int next = myRoute.get(i+1);
					if (cur[item] != next)
						System.out.print("("+(next+1)+")");
				}

				// Between items.
				System.out.print(" ");
			}

			// Blank line after each case.
			System.out.println("\n");
		}
	}
}