while 1:b,a=map(int,raw_input().split());q=a**9-1;print b**9/q%q
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page