import sys
while True:
    try:
        ips = list(map(int, input().split('.')))
        sum_ip = 0
        for ip in ips:
            sum_ip = ip + (sum_ip << 8)
        print(sum_ip)

        sum_ip = int(input())
        ips = [0,0,0,0]
        for i in range(4):
            ips[4 - 1 - i] = str(sum_ip % (2**8))
            sum_ip = (sum_ip >> 8)
        print('.'.join(ips))

    except:
#         print(sys.exc_info())
        break