#include<bits/stdc++.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define  SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define nl "\n"
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define F first
#define S second
#define len(a) a.size()
#define sz(v) (int)(v.size())
#define pii pair<int,int>
const int N = 2e5 + 1;
const int md = 998244353;
const int mod = 1e9 + 7;
const int mx = 1e5 + 12;
const int mega = 1e6 + 3;
void solve(){
  ll n,m;
  cin>>n>>m;
  ll sum=n*m;
  ll c=0;
  if(n==m){
    c=1;
    sum-=n*m;
  }
  if(n<m)swap(n,m);
  for(int i=n-1+c; i>=1; i--){
    for(int j=i; j>=1; j--){
      sum+=n*m/(i*j)*(i*j);
      sum%=mod;
    }
  }
  cout<<sum<<endl;
}
signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1;
    //in >> test;
    while (test--)
    {
        solve();
    }
}
