#include #include using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b)-1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template ostream& operator<<(ostream& os, vector& vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : " "); } return os; } using ll = long long; using vb = vector; using vvb = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using mint = modint998244353; using vm = vector; using vvm = vector; inline ostream& operator<<(ostream& os, const mint P) { return os << P.val(); }; template class Factorial { public: Factorial(int max) : n(max) { f = std::vector(n + 1); finv = std::vector(n + 1); f[0] = 1; for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i; finv[n] = f[n].inv(); for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * i; } mint fact(int k) const { assert(0 <= k && k <= n); return f[k]; } mint fact_inv(int k) const { assert(0 <= k && k <= n); return finv[k]; } mint binom(int k, int r) const { assert(0 <= k && k <= n); if (r < 0 || r > k) return 0; return f[k] * finv[r] * finv[k - r]; } mint inv(int k) const { assert(0 < k && k <= n); return finv[k] * f[k - 1]; } private: int n; std::vector f, finv; }; void solve() { int h, w, q; cin >> h >> w >> q; Factorial fact(3000000); while (q--) { int t; cin >> t; mint ans = fact.binom(h + w, h) - fact.binom(h + w, h + t); if ((ll)t * (h + t - w) < 0) ans = 0; cout << ans << "\n"; } } int main() { int t = 1; // cin >> t; while (t--) solve(); }