s = input() a = [20104, 20063, 19892, 20010, 19874, 20199, 19898, 20163, 19956, 19841] count = [0] * 10 if int(s[0]) == 3: a[3] -= 1 else: print(s[0],3) exit() for S in s[2:]: a[int(S)] -= 1 for i in range(10): if a[i] == -1: ans1 = i if a[i] == 1: ans2 = i print(ans1,ans2)