# -----------------------------------------------------------------------------------------
# Oak Valley Coding Club 2019-2020
# Solution for 2020 ACSL Programming Problem #3 – Junior Division
# Author :  Rahul Varma
# Language: Python 3.x
# -----------------------------------------------------------------------------------------



import ovcc_grader_strings
def HexToBinary(S1):
    Hex1 = S1[0]
    Hex2 = S1[1]
    Int1 = 0
    Int2 = 0
    a = 0
    b = 0
    c = 0
    d = 0
    e = 0
    f = 0
    g = 0
    h = 0
    
    if (Hex1 == 'A'):
        Int1 = 10
    elif (Hex1 == 'B'):
        Int1 = 11
    elif (Hex1 == 'C'):
        Int1 = 12
    elif (Hex1 == 'D'):
        Int1 = 13
    elif (Hex1 == 'E'):
        Int1 = 14
    elif (Hex1 == 'F'):
        Int1 = 15
    else:
        Int1 = Hex1
    
    if (Hex2 == 'A'):
        Int2 = 10
    elif (Hex2 == 'B'):
        Int2 =  11
    elif (Hex2 == 'C'):
        Int2 = 12
    elif (Hex2 == 'D'):
        Int2 = 13
    elif (Hex2 == 'E'):
        Int2 = 14
    elif (Hex2 == 'F'):
        Int2 = 15
    else:
        Int2 = Hex2
    Int1 = int(Int1)
    Int2 = int(Int2)
    
    if (Int1>=8):
        a = 1
        Int1 = Int1 - 8
    if (Int1>=4):
        b = 1
        Int1 = Int1 - 4
    if (Int1>=2):
        c = 1
        Int1 = Int1 - 2
    if (Int1>=1):
        d = 1
        Int1 = Int1 - 1

    if (Int2>=8):
        e = 1
        Int2 = Int2 - 8
    if (Int2>=4):
        f = 1
        Int2 = Int2 - 4
    if (Int2>=2):
        g = 1
        Int2 = Int2 - 2
    if (Int2>=1):
        h = 1
        Int2 = Int2 - 1
    TwoDArray = [[a,b,c,d],[e,f,g,h]]
    return TwoDArray
def Groups4(x):
    ABC1 = ""
    if (x[0][0] == 1 and x[0][1] == 1 and x[0][2] == 1 and x[0][3] == 1):
        if(ABC1 == ''):
            ABC1 = "B"
        else:
            ABC1 = ABC1 + "+B"
        x[0][0] = 0
        x[0][1] = 0
        x[0][2] = 0
        x[0][3] = 0
    if (x[1][0] ==1 and x[1][1] == 1 and x[1][2] == 1 and x[1][3] == 1):
        if(ABC1 == ''):
            ABC1 = "~B"
        else:
            ABC1 = ABC1+"+~B"
        x[1][0] = 0
        x[1][1] = 0
        x[1][2] = 0
        x[1][3] = 0
    if (x[0][0] == 1 and x[0][1] == 1 and x[1][0] == 1 and x[1][1] == 1):
        ABC1 = "A"
        x[0][0] = 0
        x[0][1] = 0
        x[1][0] = 0
        x[1][1] = 0
    if (x[0][1] == 1 and x[1][1] == 1 and x[0][2] == 1 and x[1][2] == 1):
        if(ABC1 == ''):
            ABC1 = "C"
        else:
            ABC1 = ABC1+"+C"
        x[0][1] = 0
        x[1][1] = 0
        x[0][2] = 0
        x[1][2] = 0
    if (x[0][2] == 1 and x[0][3] == 1 and x[1][2] == 1 and x[1][3] == 1):
        if(ABC1 == ''):
            ABC1 = "~A"
        else:
            ABC1 = ABC1+"+~A"
        x[0][2] = 0
        x[0][3] = 0
        x[1][2] = 0
        x[1][3] = 0
    if (x[0][0] == 1 and x[1][0] == 1 and x[0][3] == 1 and x[1][3] == 1):
        if(ABC1 == ''):
            ABC1 = "~C"
        else:
            ABC1 = ABC1+"+~C"
        x[0][0] = 0
        x[1][0] = 0
        x[0][3] = 0
        x[1][3] = 0
    #Now going to check for adjacent twos
    ABC2 = ''
    for i in range (0, 2):
        for j in range (0,3):
            if (x[i][j] == x[i][j+1] == 1):
                
                if (j +1 == 1):
                    if (i == 0):
                       if (ABC2 == ''):
                           ABC2 = "AB"
                       else:
                           ABC2 = ABC2+"+AB"
                      
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    elif (i == 1):
                       if (ABC2 == ""):
                           ABC2 = "A~B"
                       else:
                           ABC2 = ABC2+"+A~B"
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    break
                
                elif (j +1 == 2):
                    if (i == 0):
                       if (ABC2 == ''):
                           ABC2 = 'BC'
                       else:
                           ABC2 = ABC2+"+BC"
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    elif (i == 1):
                       if(ABC2 == ''):
                           ABC2 = '~BC'
                       else:
                           ABC2 = ABC2+"+~BC"
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    break
                elif(j+1 == 3):  
                    if (i == 0):
                       if(ABC2 == ''):
                           ABC2 = '~AB'
                       else:
                           ABC2 = ABC2+"+~AB"
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    elif (i == 1):
                       if(ABC2 == ''):
                           ABC2 = '~A~B'
                       else:
                           ABC2 = ABC2+"+~A~B"
                       x[i][j] =0
                       x[i][j+1] =0
                       break
                    break
    ABC3 = ''
    if (x[0][0] == x[1][0] == 1):
        ABC3 = 'A~C'
        x[0][0] = 0
        x[1][0] = 0
    if(x[0][1] == x[1][1] == 1):
        ABC3 = 'AC'
        x[0][1] = 0
        x[1][1] = 0
    if(x[0][2] == x[1][2] == 1):
        if(ABC3 == ''):
            ABC3 = '~AC'
        else:
            ABC3 = ABC3+'+~AC'
        
        x[0][2] = 0
        x[1][2] = 0
    if(x[0][3] == x[1][3] == 1):
        if(ABC3 == ''):
            ABC3 = '~A~C'
        else:
            ABC3 = ABC3+'+~A~C'
        x[0][3] = 0
        x[1][3] = 0
    ABC4 = ''
    if (x[0][0] == x[0][3] == 1):
        x[0][3] = 0
        x[0][0] = 0
        ABC4 = 'B~C'
    if (x[1][0] == x[1][3] == 1):
        x[1][3] = 0
        x[1][0] = 0
        ABC4 = '~B~C'
    a = ''
    b = ''
    c = ''
    ABC5 = ''
    if (x[0][0] == 1):
        if(ABC5 == ''):
            ABC5 = 'AB~C'
        else:
            ABC5 = ABC5 + "+AB~C"
    if (x[0][1] == 1):
        if(ABC5 == ''):
            ABC5 = 'ABC'
        else:
            ABC5 =ABC5+'+ABC'
        ABC5 = 'ABC'
    if (x[0][2] == 1):
        if(ABC5 == ''):
            ABC5 = '~ABC'
        else:
            ABC5 =ABC5+'+~ABC'
    if (x[0][3] == 1):
        if(ABC5 == ''):
            ABC5 = '~AB~C'
        else:
            ABC5 =ABC5+'+~AB~C'
    if (x[1][0] == 1):
        if(ABC5 == ''):
            ABC5 = 'A~B~C'
        else:
            ABC5 =ABC5+'+A~B~C'
    if (x[1][1] == 1):
        if(ABC5 == ''):
            ABC5 = 'A~BC'
        else:
            ABC5 =ABC5+'+A~BC'
    if (x[1][2] == 1):
        if(ABC5 == ''):
            ABC5 = '~A~BC'
        else:
            ABC5 =ABC5+'+~A~BC'
    if (x[1][3] == 1):
        if(ABC5 == ''):
            ABC5 = '~A~B~C'
        else:
            ABC5 =ABC5+'+~A~B~C'
    ABC12345 = [ABC1,ABC2,ABC3,ABC4,ABC5]
    x = 0
    for i in range(0,5):
        if (ABC12345[i] == ''):
            x = x+1
    for i in range(0,x):
        ABC12345.remove('')
    STR = '+'
    Final = STR.join(ABC12345)
    return Final
input = ovcc_grader_strings.readinput()

ovcc_grader_strings.clearoutput()
for line in input:
  S1 = line[0]
  x = HexToBinary(S1)
  ovcc_grader_strings.writeoutput(Groups4(x))