#!ruby -na eval"f=->x,m{n=o=m r=i=1 (o%i<1&&n-=n/i o/=i while o%i<1)until o0&&r*=s s*=s%m i/=2} r%m} i=j=1 i+=1while j!=j=f[i,'}] puts [i,j]*' '"