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 ip = in.nextLine();
String num = in.nextLine();
System.out.println(change(ip));
System.out.println(change(num));
}
}
public static String change(String s) {
int n = s.length();
//0 ip 1 数字
int type = s.contains(".") ? 0 : 1;
String res = null;
if(type == 0) {
long sum = 0;
String[] split = s.split("\\.");
for(int j = 0; j < 4; j++) {
int cur = Integer.parseInt(split[j]);
sum += resolve(cur, j);
}
res = sum + "";
} else {
long cur = Long.parseLong(s);
res = resolve_(cur);
}
return res;
}
public static String resolve_(long cur) {
StringBuffer b = new StringBuffer();
StringBuffer b2 = new StringBuffer();
int off = 0;
int num = 0;
for(int move = 0; move < 32; move++) {
long bit = cur % 2;
if (bit == 1) cur -= 1;
cur = cur / 2;
num += (int)Math.pow(2, off) * bit;
off++;
if(off % 8 == 0) {
b2.append(num + ".");
num = 0;
off = 0;
}
}
String[] split = b2.toString().split("\\.");
for(int i = 0; i < 4; i++) {
b.append(split[3-i] + ".");
}
b.deleteCharAt(b.length()-1);
return b.toString();
}
public static long resolve(int cur, int off) {
int base = (3-off) * 8;
long sub = 0l;
for(int move = 0; move < 8; move++) {
if (cur != 0) {
if(cur % 2 != 0) {
sub += (long)Math.pow(2, base);
cur -= 1;
}
}
cur /= 2;
base++;
}
return sub;
}
}