// Arup Guha
// 7/27/2013
// Solution to 2012 East Central Regional Problem E: Parencedence!

import java.util.*;

public class e {

	public static int n;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in expression.
			n = stdin.nextInt();
			String[] expr = new String[2*n+1];
			for (int i=0; i<expr.length; i++)
				expr[i] = stdin.next();

			System.out.println("Case "+loop+":");
			int[] p1 = solve(expr, true);
			int[] p2 = solve(expr, false);

			// Print out best paths.
			System.out.println("Player 1 ("+expr[2*p1[1]]+expr[2*p1[1]+1]+expr[2*p1[1]+2]+") leads to "+p1[0]);
			System.out.println("Player 2 ("+expr[2*p2[1]]+expr[2*p2[1]+1]+expr[2*p2[1]+2]+") leads to "+p2[0]);

			// Print final outcome.
			if (p1[0] > -p2[0])
				System.out.println("Player 1 wins");
			else if (p1[0] < -p2[0])
				System.out.println("Player 2 wins");
			else
				System.out.println("Tie");
		}

	}

	// Wrapper function, we have to do our first level call from in here to save the appropriate assignment.
	public static int[] solve(String[] expr, boolean first) {

		int[] perm = new int[n];
		boolean[] used = new boolean[n];
		boolean assigned = false;
		int best = 0, besti=0;

		// Try each choice first.
		for (int i=0; i<n; i++) {
			perm[0] = i;
			used[i] = true;

			// Other team is playing, so flip first...
			int temp = solveRec(expr, !first, 1, used, perm);
			if (!assigned || (first && temp > best) || (!first && temp < best)) {
				besti = i;
				best = temp;
			}
			used[i] = false;
			assigned = true;
		}

		int[] ans = {best, besti};
		return ans;
	}

	// Recursively solves problem.
	public static int solveRec(String[] expr, boolean first, int k, boolean[] used, int[] perm) {

		// Finished a branch.
		if (k == n)
			return eval(expr, perm);

		boolean assigned = false;
		int best = 0;

		// Same as wrapper function.
		for (int i=0; i<n; i++) {
			if (!used[i]) {
				perm[k] = i;
				used[i] = true;
				int temp = solveRec(expr, !first, k+1, used, perm);
				if (!assigned || (first && temp > best) || (!first && temp < best))
					best = temp;
				used[i] = false;
				assigned = true;
			}
		}
		return best;
	}

	public static int eval(String[] expr, int[] perm) {

		// Need to do this to evaluate recursively...
		int[] revperm = new int[perm.length];
		for (int i=0; i<perm.length; i++)
			revperm[perm[i]] = i;

		return evalRec(expr, revperm, 0, expr.length-1);
	}

	// start and end are indexes into expr, not perm
	public static int evalRec(String[] expr, int[] perm, int start, int end) {

		// This is easy.
		if (start == end)
			return Integer.parseInt(expr[start]);

		// Find last item in our tree to evaluate and split there.
		int maxIndex = start+1;
		for (int i=start+3; i<=end-1; i+=2) {
			if (perm[i/2] > perm[maxIndex/2])
				maxIndex = i;
		}

		// Recursively evaluate both sides.
		int left = evalRec(expr, perm, start, maxIndex-1);
		int right = evalRec(expr, perm, maxIndex+1, end);

		// Put answer back together based on operator.
		if (expr[maxIndex].equals("+"))
			return left+right;
		else if (expr[maxIndex].equals("-"))
			return left-right;
		else
			return left*right;
	}
}