#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; const int inf=1<<30; const ll INF=1LL<<62; typedef pair P; typedef pair PP; const ll MOD=998244353; const int dy[]={0,1,0,-1}; const int dx[]={1,0,-1,0}; const int mod = 1e9+7; struct mint { long long x; // typedef long long long long; mint(long long x=0):x((x%mod+mod)%mod){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;} mint operator+(const mint a) const { return mint(*this) += a;}//後ろのconstはメンバxを変更しないことを示す mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} bool operator==(const mint a) const {return a.x==x;} mint pow(unsigned long long int t) const { assert(t>=0); if (!t) return 1; //aがtで割り切れない場合には t%=(mod-1)をして良い mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2);} mint& operator/=(const mint a) { return *this *= a.inv();} mint operator/(const mint a) const { return mint(*this) /= a;} }; std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x;} std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;} struct combination { std::vector fact, ifact; combination(int n):fact(n+1),ifact(n+1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; //C=A*B vector> mat(vector > A,vector> B,int N){ //A*B vector> C(N,vector(N)); for(int i=0;i > multi_matrix(vector>x, ll y ,int N){ vector > pow(N,vector(N)); for(int i=0;i0){ if(y&1){ pow = mat(pow,x,N); } y = y>>1; x = mat(x,x,N); } return pow; } int main(){ ll A,B; cin>>A>>B; int N; cin>>N; vector T(N); // for(int i=0;i>T[i]; // } //2回の処理 vector> m(3,vector(3)); m[0][0]=A,m[0][1]=B,m[0][2]=1; m[1][0]=1; vector> once(3,vector(3,0)); once[0][0]=once[1][1]=once[2][2]=1; once[2][0]=A,once[2][1]=B; vector init={1,1,0}; vector ans(N); for(int t=0;t>T[t]; vector> tmp(3,vector(3)); tmp[0][0]=tmp[1][1]=tmp[2][2]=1; auto p=multi_matrix(m,T[t]/2,3); tmp=mat(p,tmp,3); if(T[t]%2==1){ //tmp = tmp*once tmp=mat(once,tmp,3); T[t]--; } { for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ ans[t]+=tmp[i][j]*init[j]; } } } } for(mint v:ans){ cout<