N = int(input()) Nl = list(str(N)) N0 = 0 while "7" in Nl: N = N-1000 N0 = N0+1000 Nl = list(str(N)) print(N,N0)