s=input() n=len(s) m=-~n//2 a=n//2 for d in 0,7:print((int(s[:m])+10**a-1-(s[:a][::-1]>s[m:]))%(d+10**9))