import java.util.*;


public class Main{
    public static void main(String[] arg){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextLine()){
            String[] ips = sc.nextLine().split("\\.");
            long ite = Long.parseLong(sc.nextLine());
            StringBuffer buffer = new StringBuffer();
            for(int i=0;i<ips.length;i++){
                String bi = leftZero(Integer.toBinaryString(Integer.parseInt(ips[i])));
                buffer.append(bi);
            }
            System.out.println(Long.parseLong(buffer.toString(),2));

            String tem = leftZero1(""+Long.toBinaryString(ite));
            int ip1 = Integer.parseInt(tem.substring(0,8),2);
            int ip2 = Integer.parseInt(tem.substring(8,16),2);
            int ip3 = Integer.parseInt(tem.substring(16,24),2);
            int ip4 = Integer.parseInt(tem.substring(24,32),2);
            System.out.println(ip1+"."+ip2+"."+ip3+"."+ip4);
         }
     }
    public static String leftZero(String bi){
        while(bi.length()<8){
            bi="0"+ bi;    
        }
        return bi;
    }
    public static String leftZero1(String bi){
        while(bi.length()<32){
            bi="0"+ bi;    
        }
        return bi;
    }
}