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