N = int(input()) if N == 0: print(0,0) elif N <= 7: print(1,N-1) else: S = str(N) A,B = "","" for s in S: if s == "0": A += "0" B += "0" continue if s == "1": A += "1" B += "0" continue for i in range(1,int(s)): j = int(s)-i if i != 7 and j != 7: A += str(i) B += str(j) break print(int(A),int(B))