#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; using mint = atcoder::modint998244353; int main(){ ll n,m,k; cin>>n>>m>>k; vector c(k); rep(i,0,k) cin>>c.at(i); vector dp(n*m+1,0); dp.at(0)=1; rep(i,0,n*m){ for(int j=1;j<=6;j++){ dp.at(min(i+j,n*m))+=dp.at(i); } } rep(i,0,k){ mint ans=0; rep(j,0,6){ if(n*2-c.at(i)-1-j>=0) ans+=dp.at(c.at(i))*dp.at(n*2-c.at(i)-1-j)*(6-j); if(n-c.at(i)-1-j>=0){ ans+=dp.at(c.at(i)+n)*dp.at(n-c.at(i)-1-j)*(6-j); ans-=dp.at(c.at(i))*dp.at(n)*dp.at(n-c.at(i)-1-j)*(6-j); } } cout<