###Brian Crabtree                    ###
###7/14/2012                         ###
###Solution to 'Comparing Sentences' ###

def main():
    
    #file reader object being opened
    reader = open('sentences.in', 'r')

    #read in the number of cases in the file
    cases = int(reader.readline())

    #iterate through all of the cases
    for i in range(cases):

        #take in the words
        sent1 = reader.readline().rstrip("\n").split(" ")
        sent2 = reader.readline().rstrip("\n").split(" ")

        #use set operations to find the common words
        common = list(set(sent1) & set(sent2))

        #use set operations to find the unique words
        unique = list(set(sent1) ^ set(sent2))

        #sort the lists of common and unique words
        common.sort()
        unique.sort()

        #print results based on input and specified output
        if len(unique) == 0:
            print("Come on Jill and MC, these sentences use the exact same words!")
        elif (len(common) == 0):
            print("You won’t like these sentences! They have nothing in common!")
        else:
            #iterate through the 'common' list and print words
            for j in common:
                print(j, end = " ")
            print()

            #iterate through the 'unique' list and print words
            for j in unique:
                print(j, end = " ")
            print()
        print()

main()
