#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using ull = unsigned long long; using namespace std; using namespace atcoder; using vst = vector; using ll = long long; using ld = long double; using P = pair; using vl = vector; using vvl = vector; using vP = vector

; #define rep(i, n) for (ll i = 0; i < n; i++) #define repp(i,k,n) for (ll i = k; i < n; i++) #define per(i,s,e) for(ll i = s; i >= e; i--) #define all(v) v.begin(),v.end() #define yesno(a) a ? cout << "Yes" << '\n' : cout << "No" << '\n' #define YESNO(a) a ? cout << "YES" << '\n' : cout << "NO" << '\n' #define UNOmap unordered_map #define UNOset unordered_set #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) #define debug(x) cerr << #x << " = " << x << '\n' templatevoid in(T&... a){(cin >> ... >> a);} templatevoid out(const T& a, const Ts&... b){cout << a;((cout << ' ' << b), ...);cout << '\n';} template void vin2(vector &u,vector &v){for(ll i = 0; i < (ll)v.size(); i++) in(u[i],v[i]);} template void vin(vector &v){for(ll i = 0; i < (ll)v.size(); i++)in(v[i]);} template void vout(vector &v){for(ll i = 0; i < (ll)v.size(); i++) cout << v[i] << ' ';cout << "\n";} ll INF = 1152921504606846976;ll MOD =998244353; ll MOD1 =1000000007; /* INF = 1 << 60 */ #define sl(...) ll __VA_ARGS__; in(__VA_ARGS__) using mint = modint998244353; using mint1 = modint1000000007; using mintn = modint; using vm = vector; using vvm = vector; vl dx = {0,0,1,-1}, dy = {1,-1,0,0}; //---------------------------------------------- const int MAX = 510000; mint fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i; inv[i] = MOD - inv[MOD%i] * (MOD / i); finv[i] = finv[i - 1] * inv[i]; } } // 二項係数計算 mint COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } int main(){ ios::sync_with_stdio(false);cin.tie(nullptr);cout<