#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
int mod=200907;
int qmi(int a,int k,int p)
{
int res=1;
while(k)
{
if(k&1)res=(LL)res*a%p;//组合出a^b
k>>=1;
a=(LL)a*a%p;//快速求出a^2^i(i=0~logk)
}
return res;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b,c,k;
cin>>a>>b>>c>>k;
if(b+b-a-c==0)
{
cout<<(a+(k-1)*(b-a))%mod<<endl;
}
else
{
cout<<a*qmi(b/a,k-1,mod)%mod<<endl;
}
}
return 0;
}