M=2*(10**15)
X=80846691
m1=M/X
m2=M%X
s=14025256
d=[]
p=[0]*80846692
k=t=r=rr=0
while k==0 or s!=14025256:
for c in str(s):
d.append(int(c))
t+=d[-1]
if p[t]==0:
p[t]=1
r+=(m1+(t <= m2 and t!=X))
s=(s*s)%20300713
k+=1
d+=d[:100]
t+=sum(d[:100])
a=1
b=t
while a < len(d) and b>0:
if d[a-1]>0:
b=min(b,t)
while b>0 and b < len(p) and p[b]>0:
b-=1
if b>0:
i=a
z=0
while i < len(d) and z+d[i] <= b:
z+=d[i]
if z < len(p) and z>0 and p[z]==0:
p[z]=a+1
r+=(a+1)*(m1+(z <= m2 and z!=X))
i+=1
print a,b
t-=d[a]
a+=1
print r