#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 200907;
int t, a, b, c, k;
int qp(int a, int b)
{
int res = 1 % mod;
while (b)
{
if (b & 1)
{
res = (res * a) % mod;
}
b >>= 1;
a = (a * a) % mod;
}
return res;
}
signed main()
{
cin >> t;
while (t -- )
{
cin >> a >> b >> c >> k;
int d = b - a, q = b / a;
if (a + c == 2 * b) cout << (a + (k - 1) * d % mod) % mod << endl;
else cout << a * qp(q, k - 1) % mod << endl;
}
return 0;
}