ip = list(map(int,input().split('.'))) ip_r = int(input()) out = ip[0]*(2**24) + ip[1]*(2**16) + ip[2]*(2**8) + ip[3] print(out) ip_r = '{:032b}'.format(ip_r) out_ =[] for i in range(4): out_.append(ip_r[i*8:i*8+8]) out_ = [str(int(x,2)) for x in out_] print('.'.join(out_))