ll@h,@w,A,B,a[2d3],b[2d3];Mint@k,s;A=Divisor(h,a);B=Divisor(w,b);rep[a](i,A)rep[b](j,B)s+=EulerPhi(i)*EulerPhi(j)*k**(h*w/lcm(i,j));wt(s/h/w);