N=input() L=len(N) O=[int(x) for x in N] P=[0]*L for i in range(L): if O[i]==7:O[i]-=1;P[i]=1 f=lambda X:int(''.join(map(str,X))) print(f(O),f(P))