n = int(input()) a = [input() for _ in range(n)] def rmvleading(s): if s == "0": return s t = "" nonzero = False for c in s: if c == '0': if not nonzero: t += "D" else: t += "0" else: nonzero = True t += c return t b = ["" for _ in range(n)] for i in range(n): b[i] = a[i].replace('0', 'D') b[i] = b[i].replace('8', 'B') print(hex(sum([int(x, 16) for x in b]))[2:].upper()) for i in range(n): b[i] = a[i].replace('B', '8') # replace D with 0 unless it expands the leading zeros seennonzero = False if b[i] == "0": continue if b[i] == "D": b[i] = "0" continue s = "" for c in b[i]: if c == 'D': if not seennonzero: s += 'D' else: s += '0' elif c == '0': if not seennonzero: s += 'D' else: s += '0' else: s += c seennonzero = True b[i] = s print(hex(sum([int(x, 16) for x in b]))[2:].upper())