# Takoma Park M.S.
# Jr-5
# Contest 3
# Sameer Mehta

# input file
FILE_NAME = "3jr_testdata.txt"

# create list of the values of groups in base 10 and its corresponding outputs
groups = [240,15,204,102,51,153,192,96,48,12,6,3,136,68,34,17,144,9,128,64,32,16,8,4,2,1]
corrOutput = ["B","~B","A","C","~A","~C","AB","BC","~AB","A~B","~BC","~A~B","A~C","AC","~AC","~A~C","B~C","~B~C","AB~C","ABC","~ABC","~AB~C","A~B~C","A~BC","~A~BC","~A~B~C"]

# open file
with open(FILE_NAME) as f:

    # for every line in the file
    for line in f:

        # turn the line into a number
        number = int(line.strip(),base=16)

        # create output list
        output = []

        # for each of the 26 groups
        for i in range(26):

            # if the group is in the number
            if (number&groups[i]) == groups[i]:

                # add it to the output list
                output.append(corrOutput[i])

                # subtract the group from the number
                number -= groups[i]

        # print output
        print("+".join(output))