//g++ 2.cpp -std=c++14 -O2 -I . #include using namespace std; #include using namespace atcoder; using ll = long long; using ld = long double; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using vld = vector; using vvld = vector; using vst = vector; using vvst = vector; #define fi first #define se second #define pb push_back #define pq_big(T) priority_queue,less> #define pq_small(T) priority_queue,greater> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) //p*q行列aとr*s行列bの積(mod) template vector> matmulti(const vector> &a,const vector> &b,X mod){ int p=a.size(),q=a[0].size(),r=b.size(),s=b[0].size(); if(q!=r){ cout<<"WARNING : SIZE ERROR"<> res(p,vector(s,0)); for(int i=0;i vector> matpower(const vector> &mat,ll n,X mod){ int x=mat.size(); if(n==0){ vector> res(x,vector(x,0)); for(int i=0;i> p=matpower(mat,n/2,mod); vector> res=matmulti(p,p,mod); return res; } vector> p=matpower(mat,n/2,mod),q=matpower(mat,n%2,mod); vector> res=matmulti(matmulti(p,p,mod),q,mod); return res; } constexpr ll mod = 1e9+7; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); /* R G B x y 0 0 x y Ax+By 1 Ax+By x 0 2 (A B) (x) (1 0) (y) */ ll a,b; cin>>a>>b; vvll m={{a,b},{1,0}}; int n; cin>>n; while(n--){ ll t; cin>>t; ll z=t/2; vvll p=matpower(m,z,mod); ll ans=0; rep(i,0,2){ rep(j,0,2){ ans+=p[i][j]; } } ll r=p[0][0]+p[0][1]; ll g=p[1][0]+p[1][1]; if(t%2==1){ ans+=r*a+g*b; } cout<