//Jono Jenkens
//ACSL Contest #3 
//Cary Academy INT-3

def veitch_square(x):
    chars = ['A', 'B', 'C', 'D']
    combined = [['0', '0', '0', '0'],
    ['0', '0', '0', '0'],
    ['0', '0', '0', '0'],
    ['0', '0', '0', '0']]
    for y in x:
        tables = []
        variables = [c for c in y]
        no = False
        for v in variables:
            if v in chars and not no:
                tables.append(ttable(v))
            elif v in chars and no:
                no = False
                tables.append(nottable(v))
            else:
                no = True
        base = tables[0]
        for table in tables:
            for a in range(4):
                for b in range(4):
                    if base[a][b] != table[a][b]:
                        base[a][b] = '0'
        for a in range(4):
            for b in range(4):
                if base[a][b] == '1':
                    combined[a][b] = '1'
    total = ''
    for row in combined:
        total += hex(int(''.join(row), 2))[2:].upper()
    print(total)
def ttable(v):
    tables = {'A':
        [['1', '1', '0', '0'],
        ['1', '1', '0', '0'],
        ['1', '1', '0', '0'],
        ['1', '1', '0', '0']], 
        'B' : 
        [['1', '1', '1', '1'],
        ['1', '1', '1', '1'],
        ['0', '0', '0', '0'],
        ['0', '0', '0', '0']],
        'C' :
        [['0', '1', '1', '0'],
        ['0', '1', '1', '0'],
        ['0', '1', '1', '0'],
        ['0', '1', '1', '0']],
        'D' :
        [['0', '0', '0', '0'],
        ['1', '1', '1', '1'],
        ['1', '1', '1', '1'],
        ['0', '0', '0', '0']]}
    return tables.get(v)
def nottable(v):
    nottables = {'A':
        [['0', '0', '1', '1'],
        ['0', '0', '1', '1'],
        ['0', '0', '1', '1'],
        ['0', '0', '1', '1']], 
        'B' : 
        [['0', '0', '0', '0'],
        ['0', '0', '0', '0'],
        ['1', '1', '1', '1'],
        ['1', '1', '1', '1']],
        'C' :
        [['1', '0', '0', '1'],
        ['1', '0', '0', '1'],
        ['1', '0', '0', '1'],
        ['1', '0', '0', '1']],
        'D' :
        [['1', '1', '1', '1'],
        ['0', '0', '0', '0'],
        ['0', '0', '0', '0'],
        ['1', '1', '1', '1']]}
    return nottables.get(v)

if __name__ == "__main__":
    for x in open('input.txt').readlines():
        veitch_square(x.rstrip().split('+'))