ip = input()
ans = 0
for s in ip.split("."):
    ans = ans * 256 + int(s)
print(ans)

arr = []
num = int(input())
for i in range(4):
    arr.append(str(num % 256))
    num //= 256
print(".".join(arr[::-1]))