ip = list(map(int,input().split('.'))) num = int(input()) ip_num = '' for i in ip: ip_num += bin(i)[2:].rjust(8,'0') print(int(ip_num,2)) num_ip = [] n = bin(num)[2:].rjust(32,'0') for i in range(4): num_ip.append(int(n[i*8:i*8+8],2)) print('.'.join(list(map(str,num_ip))))