#include using namespace std; #include using namespace atcoder; #define rep_(i, a_, b_, a, b, ...) for (int i = (a), lim##i = (b); i < lim##i; ++i) #define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) #define drep_(i, a_, b_, a, b, ...) for (int i = (a)-1, lim##i = (b); i >= lim##i; --i) #define drep(i, ...) drep_(i, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, 0) #define all(x) (x).begin(), (x).end() template using V = vector; using ld = long double; using Vi = V; using mint = modint998244353; // O(m + log mod) // only for mod > m template struct factorial { private: int MAX; vector _fac, _invf; public: factorial(int m = -1) { if (m < 0) return; MAX = m; _fac.assign(m+1, 1); _invf.assign(m+1, 1); rep(i, 2, m+1) _fac[i] = _fac[i-1] * i; _invf[m] /= _fac[m]; drep(i, m+1, 3) _invf[i-1] = _invf[i] * i; } T fac(int n) const { return _fac[n]; } T inv_fac(int n) const { return _invf[n]; } }; int solve() { int n, k; cin >> n >> k; factorial fc(k); Vi a(n); for (auto &e : a) cin >> e; int S = accumulate(all(a), 0); priority_queue> pq; rep(i, n) pq.emplace(ld(a[i]) / S, i); Vi x(n); rep(_, k) { auto [z, i] = pq.top(); pq.pop(); x[i]++; pq.emplace(ld(a[i]) / S / (x[i]+1), i); } mint ans = fc.fac(k) / mint(S).pow(k); rep(i, n) { ans *= mint(a[i]).pow(x[i]); ans *= fc.inv_fac(x[i]); } return ans.val(); } int main() { int t; cin >> t; rep(i, t) cout << solve() << '\n'; }