#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include #include #include #include #include #include #include #include using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i=0; i--) const i64 INF = 1001001001001001001; #include using Modint = atcoder::static_modint<10000'00007>; using namespace std; void testcase(){ Modint P; { int p; cin >> p; P = p; } vector D(5); D[1] = P * 2; D[2] = -P*P + 2; D[3] = -P * 2; D[4] = -1; int Z = 2000100; vector A(Z); A[4] = 1; for(int i=5; i> Q; rep(q,Q){ int a; cin >> a; cout << A[a].val() << '\n'; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }