用format补全0的位数即可

while True:
    try:
        s1=input().split('.')
        s2=format(bin(int(input()))[2:],'0>32')
        l=''
        for a in s1:
            l+=format(bin(int(a))[2:],'0>8')
        print(int(l,2))
        s=[]
        for i in range(0,32,8):
            s.append(str(int(s2[i:i+8],2)))
        print('.'.join(s))

    except:
        break