h,w=map(int,input().split()) n=max(h,w) m=min(h,w) M=10**9+7 L=2*10**5 fa=[1,1] fb=[1,1] for i in range(2,L+1): fa+=[fa[-1]*i%M] fb+=[fb[-1]*(M//i)*fb[M%i]*fa[M%i-1]*(-1)%M] c=lambda n,k:fa[n]*fb[k]*fb[n-k]%M if n>=k else 0 q=[0]*m f=lambda l,i:c((l//i)+1,2)*((l%i)+1)+c((l//i)-1+1,2)*(i-(l%i)-1) for i in range(1,m): g=1 g*=f(h-1,i) g*=f(w-1,i) q[i]=g P=[1]*(L+1) for i in range(2,L+1): if P[i]: for j in range(i+i,L+1,i): P[j]=0 P=[i for i in range(2,L+1) if P[i]] for p in P: for i in range(1,m): if i*p