#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define M 1000000007
using namespace std;
int main()
{
fastio;
int t;
cin >> t;
while(t--)
{
long n,a;
cin >> n >> a;
ll ans=0,x=a,y;
for(long i=1;i<=n;i++)
{
y=pow(x,(2*i-1));
ans=(ans%M+y%M)%M;
x=(x*y)%M;
}
cout << ans << "\n";
}
}
Given this input
1
4 10
I'm getting a garbage value back. Why is that?
However, for this input:
1
3 2
The answer I'm getting back seems totally fine.