import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextLine()) { // 注意 while 处理多个 case
String a = in.nextLine();
long b = Long.parseLong(in.nextLine());
System.out.println(ipToLong(a));
System.out.println(longToIp(b));
}
}
public static long ipToLong(String ip) {
String[] array = ip.split("\\.");
long sum = (Long.parseLong(array[0])<<24) + (Long.parseLong(array[1])<<16) + (Long.parseLong(array[2])<<8) + (Long.parseLong(array[3]));
return sum;
}
public static String longToIp(long sum) {
long n4 = (sum>>24);
sum -= (n4<<24);
long n3 = (sum)>>16;
sum -= (n3<<16);
long n2 = (sum)>>8;
sum -= (n2<<8);
long n1 = sum;
String ip = "" + n4 + "." + n3 + "." + n2 + "." + n1;
return ip;
}
}