def iptoint(s):
ip_list=s.strip().split('.')
n=''
for i in ip_list:
n+=bin(int(i))[2:].zfill(8)
result=int(n,2)
return result
def inttoip(s):
ip=''
n=bin(int(s))[2:].zfill(32)
for i in range(0,32,8):
ip+=str(int(n[i:i+8],2))
ip+="."
return ip[:-1]
while 1:
try:
ip=input()
num=input()
print(iptoint(ip))
print(inttoip(num))
except:
break