#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define fix(x) fixed << setprecision(x) #define eb emplace_back constexpr char nl='\n'; using namespace std; using ll = long long; using ld = long double; using vl = vector; using vvl = vector>; using vs = vector; using pl = pair; template inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;} template inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;} templateusing rp_queue=priority_queue,greater>; void fast_io(){cin.tie(nullptr);ios_base::sync_with_stdio(false);} template T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);} template inline T lcm(T a, T b) {return a /gcd(a, b)*b;} const ll INF = 1LL << 60; const ld PI = acos(-1); const long long mod = 1e9 + 7; vvl mul(vvl &a,vvl &b){ vvl c(2,vl(2)); rep(i,2){ rep(j,2){ rep(k,2){ c[i][j] = (c[i][j]+a[i][k]*b[k][j])%mod; } } } return c; } vvl pow(vvl &A,ll N){ vvl C(2,vl(2)); rep(i,2)C[i][i]=1; while(N>0){ if(N&1){ C = mul(C,A); } A = mul(A,A); N >>= 1; } return C; } void solve(){ ll a,b,N;cin>>a>>b>>N; vvl A(2,vl(2)); A[0][0] = a; A[0][1] = b; A[1][0] = 1; A[1][1] = 0; //AのN乗を求める A = pow(A,N); cout<> num_tc; rep(tc,num_tc){ //cout << "Case #" << tc+1 << ": " ;// << endl; solve(); } }