import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String ip = in.nextLine();
            long longInt = Long.parseLong(in.nextLine());
            System.out.println(ipToLongInt(ip));
            System.out.println(longIntToip(longInt));
        }
    }
    //根据ip地址展开成二进制的特点,四个部分的权重分别为2^24,2^16,2^8,2^0
    public static long ipToLongInt(String ip){
        String[] ipi = ip.split("\\.");
        long res = 0;
        for(int i=ipi.length-1;i>=0;i--){
            res += Long.parseLong(ipi[i]) * Math.pow(2,8*(ipi.length-1-i));
        }
        return res;
    }
    //对2^8取余的低位,取整去掉低位
    public static String longIntToip(long longInt){
        StringBuilder sb = new StringBuilder();
        long ipi = 0;
        while(longInt>0){
            ipi = longInt % (long)Math.pow(2,8);//ip的低位
            longInt = longInt / (long)Math.pow(2,8);//去掉低八位
            if(sb.length()==0){//添加最低位
                sb.append(ipi);
            }else{
                sb.insert(0,".").insert(0,ipi);
            }
        }
        return sb.toString();
    }
}