for j=0to 49input""x,y:for i=-int(log(x,y))to 0?"",int(mod(x*y^i,y));next:?next