ll@h,@w,s,t,I[2000],J[2000];mint@k,a;s=Divisor(h,I);t=Divisor(w,J);rep[I](i,s)rep[J](j,t)a+=EulerPhi(i)*EulerPhi(j)*k**(h*w/lcm(i,j));wt(a/h/w);