// Arup Guha
// 4/10/2021
// Solution to 2021 Code Jam Round 1A Problem C (first 2 test sets only): Hacked Exam

import java.util.*;

public class Solution {

	public static int n;
	public static boolean[] s1;
	public static boolean[] s2;
	public static int c1;
	public static int c2;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process all cases.
		for (int loop=1; loop<=nC; loop++) {
		
			int nS = stdin.nextInt();
			n = stdin.nextInt();
			
			// Case for 1.
			if (nS == 1) {
			
				// Read in stuff.
				char[] tmp = stdin.next().toCharArray();
				s1 = new boolean[n];
				for (int i=0; i<n; i++)
					s1[i] = (tmp[i] == 'T');
				c1 = stdin.nextInt();
				
				// We copy their answers in this case.
				if (2*c1 >= n) {
					System.out.print("Case #"+loop+": ");
					System.out.print(new String(tmp));
					System.out.println(" "+c1+"/1");
				}
				
				// Flip their answer case.
				else {
				
					// Flip the string.
					int flip = n - c1;
					for (int i=0; i<n; i++) tmp[i] = tmp[i] == 'T' ? 'F' : 'T';
					
					// Output.
					System.out.print("Case #"+loop+": ");
					System.out.print(new String(tmp));
					System.out.println(" "+flip+"/1");					
				}
					
			}
			
			// We have two sets of data.
			else if (nS == 2) {
			
				// Read in both.
				String tmp = stdin.next();
				s1 = new boolean[n];
				for (int i=0; i<n; i++)
					s1[i] = (tmp.charAt(i) == 'T');		
				c1 = stdin.nextInt();
				
				tmp = stdin.next();
				s2 = new boolean[n];
				for (int i=0; i<n; i++)
					s2[i] = (tmp.charAt(i) == 'T');	
				c2 = stdin.nextInt();
				
				// Count # of same and different responses.
				int numS = 0, numD = 0;
				boolean[] same = new boolean[n];
				for (int i=0; i<n; i++) {
					if (s1[i] == s2[i]) {
						numS++;
						same[i] = true;
					}
					else {
						numD++;
						same[i] = false;
					}
				}
				
				// Make c1 the better student.
				if (c2 > c1) {
					int z = c2;
					c2 = c1;
					c1 = z;
					boolean[] copy = s1;
					s1 = s2;
					s2 = copy;
				}
				
				// How much better s1 did than s2.
				int diff = c1-c2;
				int s2ScoreOnDiff = (numD-diff)/2;
				int s1ScoreOnDiff = s2ScoreOnDiff + diff;
				
				int onRest = c1 - s1ScoreOnDiff;
				
				// Keep both students' answers on same questions, use s1 answers on different
				if (2*onRest >= numS) {
					int score = s1ScoreOnDiff + onRest;
					char[] res = new char[n];
					for (int i=0; i<n; i++) res[i] = s1[i] ? 'T' : 'F';
					System.out.print("Case #"+loop+": ");
					System.out.print(new String(res));
					System.out.println(" "+score+"/1");					
				}
				
				// Use s1's answers on diff, and flip answers on same.
				else {
					int score = s1ScoreOnDiff + (numS-onRest);
					char[] res = new char[n];
					for (int i=0; i<n; i++) {
						if (same[i])
							res[i] = s1[i] ? 'F' : 'T';
						else
							res[i] = s1[i] ? 'T' : 'F';
					}
					System.out.print("Case #"+loop+": ");
					System.out.print(new String(res));
					System.out.println(" "+score+"/1");					
				}	
			}
			
			// Not doing this case (for now anyway)!
			else {
				stdin.next();stdin.nextInt();
				stdin.next();stdin.nextInt();
				stdin.next();stdin.nextInt();
				System.out.println("Case #"+loop+":");
			}
		}
	}
}