#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
  long long n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << "2" << endl;
  } else {
    long long ans = n * (m + 1);
    ans = ans % mod;
    cout << ans << endl;
  }
  return 0;
}
