// Arup Guha
// 4/23/2013
// Solution to 2013 UCF High School Contest Problem: Battle of the Best

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

public class best {
	
	public static void main(String[] args) throws Exception {
		
		Scanner fin = new Scanner(new File("best.in"));
		int numCases = Integer.parseInt(fin.nextLine().trim());
		
		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {
			
			// Parse out all of the data.
			String p1 = fin.nextLine();
			String p2 = fin.nextLine();
			int nump1 = Integer.parseInt(fin.nextLine().trim());
			String[] p1Moves = new String[nump1];
			for (int i=0; i<nump1; i++)
				p1Moves[i] = fin.nextLine();
				
			int nump2 = Integer.parseInt(fin.nextLine().trim());
			String[] p2Moves = new String[nump2];
			for (int i=0; i<nump2; i++)
				p2Moves[i] = fin.nextLine();
			
			// Now, print the battle, using the rules.
			System.out.println("Battle #"+loop+"! BEGIN!!!");
			int i;
			for (i=0; i<Math.min(nump1, nump2); i++) {
				System.out.println(p1+" uses "+p1Moves[i]+"!");
				System.out.println(p2+" uses "+p2Moves[i]+"!");
			}
			if (nump1 > nump2) {
				System.out.println(p1+" uses "+p1Moves[i]+"!");
				System.out.println(p2+" is defeated by "+p1+"\'s "+p1Moves[i]+"!!!");
			}
			else {
				System.out.println(p1+" is defeated by "+p2+"\'s "+p2Moves[i-1]+"!!!");
			}
			System.out.println();
		}
	}
}

