#include #include #define INF 4611686018427387903ll using namespace std; using namespace atcoder; using ll = long long; using mint = modint1000000007; struct Matrix22 { mint v11, v12, v21, v22; Matrix22(void){ this->v11 = 1; this->v12 = 0; this->v21 = 0; this->v22 = 1; } Matrix22(mint v11, mint v12, mint v21, mint v22) { this->v11 = v11; this->v12 = v12; this->v21 = v21; this->v22 = v22; } Matrix22 operator*(const Matrix22 other) const { return Matrix22((this->v11 * other.v11) + (this->v12 * other.v21), (this->v11 * other.v12) + (this->v12 * other.v22), (this->v21 * other.v11) + (this->v22 * other.v21), (this->v21 * other.v12) + (this->v22 * other.v22)); } pair operator*(const pair other) const { return pair((this->v11 * other.first) + (this->v12 * other.second), (this->v21 * other.first) + (this->v22 * other.second)); } Matrix22 pow(ll n){ Matrix22 ret = Matrix22(); Matrix22 A = *this; while(n){ if(n & 1){ ret = A * ret; } A = A * A; n >>= 1; } return ret; } }; int main(){ ll a, b; cin >> a >> b; ll n; cin >> n; Matrix22 A(a, b, 1, 0); pair v(1, 1); for(int i = 0; i < n; ++i){ ll t; cin >> t; ll d = t / 2, r = t % 2; pair v1 = A.pow(d) * v; pair v2 = A * v1; mint ans = 0; if(r == 1){ ans = v1.first + v1.second + v2.first; } else{ ans = v1.first + v1.second; } cout << ans.val() << endl; } }