#Aarav Gupta
#Cary Academy - INT-3
#Contest 3

file = open(r"acsl\input3.txt","r")

inp = file.read().splitlines()

file.close()

letters = {
    "A": [[[i, 0], [i, 1]] for i in range(4)], "~A": [[[i, 2], [i, 3]] for i in range(4)], 
    "B": [[[0, i], [1, i]] for i in range(4)], "~B": [[[2, i], [3, i]] for i in range(4)], 
    "C": [[[i, 1], [i, 2]] for i in range(4)], "~C": [[[i, 0], [i, 3]] for i in range(4)], 
    "D": [[[1, i], [2, i]] for i in range(4)], "~D": [[[0, i], [3, i]] for i in range(4)]
    }
answers = []
for inpy in inp:
    final = []
    veitch = [[False for i in range(4)] for i in range(4)]

    for boolean in inpy.split("+"):
        exp = [boolean[i] for i in range(len(boolean))]
        i = 0
        seperate = 0
        possible = []
        while(i < len(exp)):
            temp = exp[i]
            if(temp[0] == "~"):
                temp = "".join([temp[0], str(exp[i+1])])
                i += 1
            temp = str(temp)
            t2 = letters[temp][0]+letters[temp][1]+letters[temp][2]+letters[temp][3]
            possible.extend(t2)
            
            seperate+=1
            i+=1

        for x in possible:
            if(possible.count(x) >= seperate and (not x in final)):
                final.append(x)
        
    for x in final:
        veitch[x[0]][x[1]] = True

    on = [[], [], [], []]
    r=0
    for row in veitch:
        c=0
        string = ""
        for element in row:
            if(element):
                on[r].append(c)
                string += "x  "
            else:
                string += "o  "

            c+=1
        r+=1

    returnString = ""
    for thing in on:
        num = 0
        for i in thing:
            num += (2**(3-i))
        returnString += str(hex(num))[2:]
    
    answers.append(returnString)
    final = []
    print("------------------")
    print(returnString.upper())

print("------------------")