#include #include using namespace std; using mint = atcoder::modint998244353; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; const int r = n * m; vector dp(n * m + 7), tb(n * m + 1); dp[0] = 1; for(int i = 0; i < n * m; i++){ for(int j = 1; j <= 6; j++){ dp[i + j] += dp[i]; tb[i + 1] += dp[i + j]; } } while(k--){ int v; cin >> v; mint ans = dp[v] * tb[r - v] + dp[n + v] * tb[r - (n + v)]; ans -= dp[v] * dp[n] * tb[r - (n + v)]; cout << ans.val() << '\n'; } }