Pagini recente » Cod sursa (job #1488023) | Cod sursa (job #2589140) | Cod sursa (job #1434144) | Cod sursa (job #2621835) | Cod sursa (job #2753287)
#include <bits/stdc++.h>
//#pragma GCC optimize ("03")
#define FastIO ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define FILES freopen("iepuri.in" , "r" , stdin) , freopen("iepuri.out" , "w" , stdout)
#define ll long long
#define ull unsigned long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < ll , ll >
#define pq priority_queue
#define dbg(x) cerr << #x << ": " << x << '\n'
namespace FastRead
{
char __buff[5000];ll __lg = 0 , __p = 0;
char nc()
{
if(__lg == __p){__lg = fread(__buff , 1 , 5000 , stdin);__p = 0;if(!__lg) return EOF;}
return __buff[__p++];
}
template<class T>void read(T&__x)
{
T __sgn = 1; char __c;while(!isdigit(__c = nc()))if(__c == '-')__sgn = -1;
__x = __c - '0';while(isdigit(__c = nc()))__x = __x * 10 + __c - '0';__x *= __sgn;
}
}
using namespace FastRead;
using namespace std;
const ll N = 1e5 + 10;
const ll M = 666013;
const ld PI = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll A , B , C , X , Y , Z , n;
ll a[5][5] , ans[5][5] , b[5][5] , f[6] , c[5][5];
void mul(ll a[][5] , ll b[][5])
{
ll j;
for(ll i = 1 ; i <= 3 ; i++)
for(j = 1 , c[i][j] = 0 ; j <= 3 ; j++ , c[i][j] = 0)
for(ll t = 1 ; t <= 3 ; t++)
c[i][j] = (c[i][j] + a[i][t] * b[t][j] % M) % M;
for(ll i = 1 ; i <= 3 ; i++)
for(ll j = 1 ; j <= 3 ; j++)
a[i][j] = c[i][j];
}
void pw(ll p)
{
for( ; p ; p >>= 1 , mul(a , a))
if(p & 1)
mul(ans , a);
}
void Test()
{
cin >> f[0] >> f[1] >> f[2] >> A >> B >> C >> n;
a[1][1] = A , a[1][2] = B , a[1][3] = C;
a[2][1] = 1 , a[2][2] = 0 , a[2][3] = 0;
a[3][1] = 0 , a[3][2] = 1 , a[3][3] = 0;
ans[1][1] = 1 , ans[1][2] = 0 , ans[1][3] = 0;
ans[2][1] = 0 , ans[2][2] = 1 , ans[2][3] = 0;
ans[3][1] = 0 , ans[3][2] = 0 , ans[3][3] = 1;
pw(n - 2);
cout << (ans[1][1] * f[2] + ans[1][2] * f[1] + ans[1][3] * f[0]) % M << '\n';
}
signed main()
{
#ifndef ONLINE_JUDGE
FastIO , FILES;
#endif
ll q; cin >> q;
while(q--) Test();
return 0;
}