/************************************\
|Brian Crabtree                      |
|7/14/2012                           |
|Solution to 'Comparing Sentences'   |
\************************************/

import java.io.*;
import java.util.*;

public class sentences
{
	public static void main(String[] args) throws IOException
	{
		
		//scanner to read in from file
		Scanner in = new Scanner(new File("sentences.in"));
		
		//read in the number of cases
		int cases = Integer.parseInt(in.nextLine());
		
		//iterate through all of the input cases
		for(int i = 0; i < cases; i++)
		{
			//ArrayLists to store values for the two inputted sentences and which words are common and unique
			ArrayList<String> sent1 = new ArrayList<String>();
			ArrayList<String> sent2 = new ArrayList<String>();
			ArrayList<String> common = new ArrayList<String>();
			ArrayList<String> unique = new ArrayList<String>();
			
			//add all of the words in the sentences to the ArrayLists
			StringTokenizer tok = new StringTokenizer(in.nextLine());
			while (tok.hasMoreTokens())
				sent1.add(tok.nextToken());
			tok = new StringTokenizer(in.nextLine());
			while (tok.hasMoreTokens())
				sent2.add(tok.nextToken());
			
			//add words in common to the common array or if not common add to unique array based on iteration through sentence 1
			//also verify that the word is added only once
			for(int j = 0; j < sent1.size(); j++)
				if(sent2.contains(sent1.get(j)) && !common.contains(sent1.get(j)))
					common.add(sent1.get(j));
				else if(!sent2.contains(sent1.get(j)) && !unique.contains(sent1.get(j)))
					unique.add(sent1.get(j));
					
			//iterate through sentence 2 and add words to unique that have not yet been added
			for(int j = 0; j < sent2.size(); j++)
				if(!sent1.contains(sent2.get(j))&& !unique.contains(sent2.get(j)))
					unique.add(sent2.get(j));
			
			//arrays to store the sorted common and unique words	
			String[] commonS = new String[common.size()];
			String[] uniqueS = new String[unique.size()];
			
			//move the common and unique words from the ArrayLists to the arrays
			common.toArray(commonS);
			unique.toArray(uniqueS);
			
			//sort the arrays
			Arrays.sort(commonS);
			Arrays.sort(uniqueS);
			
			//print out statements based on output found
			if(common.size() == 0)
				System.out.println("You won’t like these sentences! They have nothing in common!");
			else if(unique.size() == 0)
				System.out.println("Come on Jill and MC, these sentences use the exact same words!");
			else
			{
				//iterate through common and unique sorted arrays and print out the words
				for(int j = 0; j < commonS.length; j++)
					System.out.print(commonS[j] + " ");
				System.out.println();
			
				for(int j = 0; j < uniqueS.length; j++)
					System.out.print(uniqueS[j] + " ");
				System.out.println();
			}
			
			System.out.println();
		}
		
		in.close();
	}
}