h, w = map(int,input().split()) n = max(h+1, w+1) cnt1 = [max(0,h-i) for i in range(n)] cnt2 = [max(0,w-i) for i in range(n)] isprime = [1]*n isprime[0]=0 isprime[1]=0 prime = [] for i,b in enumerate(isprime): if b == 0: continue prime.append(i) j = 2*i while j < n : isprime[j] = 0 j += i for p in prime : m = (n-1)//p for i in range(m,0,-1): cnt1[i]+=cnt1[i*p] cnt2[i]+=cnt2[i*p] cnt = [cnt1[i]*cnt2[i] for i in range(n)] for p in prime : m = (n-1)//p for i in range(1,m+1): cnt[i]-=cnt[i*p] print((2*cnt[1]+h*(w-1)+w*(h-1))%(10**9+7))