# 举例:一个ip地址为10.0.3.193
# 每段数字             相对应的二进制数
# 10                   00001010
# 0                    00000000
# 3                    00000011
# 193                  11000001
#
# 组合起来即为:00001010 00000000 00000011 11000001,转换为10进制数就是:167773121,即该IP地址转换后的数字就是它了。
# 输入:
# 10.0.3.193
# 167969729
# 输出
# 167773121
# 10.3.3.193

def to_int(ips):
    bins = ''
    for i in ips:
        # 不足8位的,要前面加0补足
        n = len(str(bin(int(i))).replace('0b', ''))
        bins += '0' * (8 - n) + str(bin(int(i))).replace('0b', '')
    return int(bins, 2)


def to_ips(n):
    ips = []
    arr = []
    ips2 = bin(n).replace('0b','')
    # print(len(ips2)) # 28
    # print(ips2)      # 1010 00000011 00000011 11000001
    # 从后面开始每8位截取一次
    for i in range(3):
        s = ips2[-8:]
        arr.append(s)
        ips2 = ips2[0:-8]
    arr.append(ips2)
    arr = arr[::-1]
    # print(arr)
    for i in arr:
        ips.append(str(int(i, 2)))
    return '.'.join(ips)
while True:
    try:
        # ips = '10.0.3.193'.split('.')
        # n = int('167969729')
        ips = input().split('.')
        n = int(input())
        print(to_int(ips))
        print(to_ips(n))
    except:
        break