import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); while(sc.hasNextLine()){ String line1 = sc.nextLine(); System.out.println(ip2num(line1)); String line2 = sc.nextLine(); long num = Long.parseLong(line2); System.out.println(num2ip(num)); } } public static Long ip2num(String ip){ String[] segs = ip.split("\\."); long sum = 0L; long mul = 1L; for(int i = segs.length - 1; i >= 0; --i){ sum += Long.parseLong(segs[i],10) * mul; mul *= 256; } return sum; } public static String num2ip(long num){ String line = Long.toBinaryString(num); int len = line.length(); int start = len - 1; StringBuilder sb = new StringBuilder(); while((start >= 0) && (start - 7 >= 0)){ sb.append(Integer.parseInt(line.substring(start - 7, start + 1), 2)); sb.append("."); start -= 8; } if(start != -1){ sb.append(Integer.parseInt(line.substring(0, start + 1), 2)); }else{ sb.deleteCharAt(sb.length() - 1); } String[] split = sb.toString().split("\\."); StringBuilder sb1 = new StringBuilder(); for(int i = split.length - 1; i > 0; --i){ sb1.append(split[i]); sb1.append("."); } sb1.append(split[0]); return sb1.toString(); } }