n = input() m = int(n.replace("7","6")) n = int(n)-m print(n,m)