#Rohan Ray
#3/12/2020
#Int 5
#Enloe
#Potter
#Contest 3


import numpy as np
filename = 'F://3int.txt'

with open(filename) as file_object:
    lines = file_object.readlines() 
        
def fill(x,notter):
    if(notter==0):
        if(x=='A'):
            for i in range(2):
                for y in range(4):
                    board[y][i]+=1
        if(x=='B'):
            for i in range(2):
                for y in range(4):
                    board[i][y]+=1
        if(x=='C'):
            for i in range(1,3):
                for y in range(4):
                    board[y][i]+=1
        if(x=='D'):
            for i in range(1,3):
                for y in range(4):
                    board[i][y]+=1
    elif(notter==1):
        if(x=='A'):
            for i in range(2,4):
                for y in range(4):
                    board[y][i]+=1
        if(x=='B'):
            for i in range(2,4):
                for y in range(4):
                    board[i][y]+=1
        if(x=='C'):
                for y in range(4):
                    board[y][0]+=1
                    board[y][3]+=1
        if(x=='D'):
                for y in range(4):
                    board[0][y]+=1
                    board[3][y]+=1
    #print(board)

def maximize(board):
    maximum =max(map(max, board))
    for i in range(len(board)):
        for j in range(len(board)):
            if(board[i][j]==maximum):
                board[i][j]=1
            else:
                board[i][j]=0

def mitigate(arr):
    for i in range(len(arr)):
        for j in range(len(arr)):
            if(arr[i][j]>1):
                arr[i][j]=1
    return arr

def transfer(board):
    boardlist.append(board)
    #print('boardlist',boardlist)

def hexer(n):
    if(n=='0000'):
        m='0'
    if(n=='0001'):
        m='1'
    if(n=='0010'):
        m='2'
    if(n=='0011'):
        m='3'
    if(n=='0100'):
        m='4'
    if(n=='0101'):
        m='5'
    if(n=='0110'):
        m='6'
    if(n=='0111'):
        m='7'
    if(n=='1000'):
        m='8'
    if(n=='1001'):
        m='9'
    if(n=='1010'):
        m='A'
    if(n=='1011'):
        m='B'
    if(n=='1100'):
        m='C'
    if(n=='1101'):
        m='D'
    if(n=='1110'):
        m='E'
    if(n=='1111'):
        m='F'
    return m
                

for line in lines:
    #print(line)
    linar=list(line)
    #linar=linar[0:len(linar)-1]
    #print(linar)
    notter=0
    current =''
    boardlist=[]
    for i in range(len(linar)):
        board = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
        if(linar[i]=='+')or(linar[i]=='\n') or(i==len(linar)-1):
            cura=list(current)
            #print(cura)
            for j in range(len(cura)):
                if(cura[j]=='~'):
                    notter=1
                    fill(cura[j],notter)
                else:
                    fill(cura[j],notter)
                    notter=0
            maximize(board)
            transfer(board)
            #print(board)
            current=''
        else:
            current+=linar[i]
    sumarr=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
    for i in range(len(boardlist)):
        sumarr=np.add(boardlist[i],sumarr)
    #print('summar',sumarr)
    sumarr = mitigate(sumarr)
    res=''
    for i in range(len(sumarr)):
        hexy=''
        row=sumarr[i]
        for digit in row:
            hexy += str(digit)
        #print('hex',hexy)
        res+=hexer(hexy)
    print(res)