N = input() A_list = list() for i in N: if i == "7": i = "6" A_list.append(i) A_str = "".join(A_list) A = int(A_str) B = int(N) - A print(A,B)