the following code fails for very large numbers .can anyone help me in fixing it??
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
/*ll pow(ll a,ll b)
{
if(b==0)
return 1ll;
if(b==1)
return a;
ll ans=pow(a,b/2);
if(b%2==0)
return (ans*ans)%mod;
else
return (((ans*ans)%mod)*a)%mod;
}*/
int main()
{
ll t;cin>>t;
while(t–)
{
ll n;ll k;cin>>n>>k;
k–;
ll ans;
if(k%2==0)
{
ll ele=(n+k/2)%mod;
ans=(ele*ele)%mod+(k/2)%mod;
}
else
{
ll ele=(n+1+k/2)%mod;
ans=(ele*ele)%mod-(k/2 +1)%mod;
}
cout<<ans%mod<<endl;
}
return 0;
}