#将十进制数转化为八位二进制数,x要小等于255
def fun1(x):
res = [0]*8
n = 0
if x == 0:
res = [0]*8
else:
while x // 2 > 0:
res[-1-n] = x % 2
n = n + 1
x = x // 2
res[-1-n] = 1
return res
#将十进制数转化为32位二进制数,x要小等于255
def fun2(x):
res = [0]*32
n = 0
if x == 0:
res = [0]*32
else:
while x // 2 > 0:
res[-1-n] = x % 2
n = n + 1
x = x // 2
res[-1-n] = 1
return res
while True:
try:
#获取输入的IP地址
data1 = input()
#获取输入的十进制IP地址
data2 = input()
list1 = data1.split('.')
n1 = len(list1)
#用于存放合并的列表
list2 = []
for k in range(0,n1):
list2 = list2 + fun1(int(list1[k]))
#此时list2为组合起来的二进制数
#将组合起来的二进制数转化为十进制数
#设置初值
num = 0
for k in range(0,len(list2)):
num = num + int(list2[-1-k])*2**k
# print(num)
#将输入的十进制IP地址转化为32位二进制数
list3 = fun2(int(data2))
#用于存储四个十进制数
list4 = []
num1 = 0
for m in range(0,4):
for n in range(0,8):
num1 = num1 + list3[-1-n-8*m]*2**n
else:
list4.append(str(num1))
num1 = 0
#因为顺序是反的,所以需要倒序排列
list5 = list4[::-1]
print(num)
print('.'.join(list5))
except:
break