i;main(a,m,x){for(;~scanf("%d%d",&a,&m);printf("%d\n",x))for(x=1,i=m-2;i;i/=2)x=i&1?x*1ll*a%m:x,a=a*1ll*a%m;}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page