#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

/*
?????? 0<=a<=m
??¬??? d
0 <= a + d(n-1) <= m

-d(n-1) <= a <= m-d(n-1)
search all d -> m-d(n-1)<0 -> O(m/n)

-a/(n-1) <= d <= (m-a)/(n-1)
*/

int main(){
  ll n,m;
  cin>>n>>m;
  ll ans = m+1;
  ans %= MOD;
  if(n>1){
    ll dmax;
    {
      // find max m-x*(n-1) >= 0
      ll ok = 0, ng = 1e17/(n-1);
      while(ok+1<ng){
        ll x = (ok+ng)/2;
        if(m-x*(n-1)>=0){
          ok = x;
        }else{
          ng = x;
        }
      }
      dmax = ok;
    }
    ll add = 0;
    dmax %= MOD;
    m %= MOD;
    n %= MOD;
    if(n==0)n=MOD;
    add += dmax * (m+1) % MOD;
    add %= MOD;
    add += MOD - ( (n-1) * (dmax * (dmax+1) / 2 % MOD) ) % MOD;
    ans += add * 2ll % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}
### Prompt

Generate a CPP solution to the following problem:

B: Ebi-chan and Integer Sequences-

problem

Ebi-chan likes sequences. I especially like arithmetic progressions. This time, I decided to create a sequence that meets the following conditions.

* Arithmetic progression of length n
* When the i-th element of the sequence is defined as s_i, all s_i (1 \ leq i \ leq n) are integers that satisfy 0 \ leq s_i \ leq m.



How many sequences are there that satisfy the above conditions? However, the answer can be very large, so print the remainder after dividing by 10 ^ 9 + 7.

Input format

Input is given in one line.


n m

n represents the length of the sequence.

Constraint

* 1 \ leq n \ leq 10 ^ {15}
* 0 \ leq m \ leq 10 ^ {15}



Output format

Divide the number of arithmetic progressions that satisfy the condition by 10 ^ 9 + 7 and output the remainder in one row.

Input example 1


3 9

Output example 1


50

Input example 2


10000000000 10000000000

Output example 2


999999942

Note that the input does not fit in a 32-bit integer.





Example

Input

3 9


Output

50

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

/*
?????? 0<=a<=m
??¬??? d
0 <= a + d(n-1) <= m

-d(n-1) <= a <= m-d(n-1)
search all d -> m-d(n-1)<0 -> O(m/n)

-a/(n-1) <= d <= (m-a)/(n-1)
*/

int main(){
  ll n,m;
  cin>>n>>m;
  ll ans = m+1;
  ans %= MOD;
  if(n>1){
    ll dmax;
    {
      // find max m-x*(n-1) >= 0
      ll ok = 0, ng = 1e17/(n-1);
      while(ok+1<ng){
        ll x = (ok+ng)/2;
        if(m-x*(n-1)>=0){
          ok = x;
        }else{
          ng = x;
        }
      }
      dmax = ok;
    }
    ll add = 0;
    dmax %= MOD;
    m %= MOD;
    n %= MOD;
    if(n==0)n=MOD;
    add += dmax * (m+1) % MOD;
    add %= MOD;
    add += MOD - ( (n-1) * (dmax * (dmax+1) / 2 % MOD) ) % MOD;
    ans += add * 2ll % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}
```