// #pragma GCC optimize ("O3") // #pragma GCC target("avx512f") // #pragma GCC optimize("unroll-loops") // #ifndef ONLINE_JUDGE // #define _GLIBCXX_DEBUG // #endif #include #include #include #include namespace mp = boost::multiprecision; using Bint=mp::cpp_int; using Real = mp::number>; #include using namespace std; using namespace atcoder; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(n) for(ll i = 0; i < (n); ++i) #define rep2(i, n) for(ll i = 0; i < (n); ++i) #define rep3(i, a, b) for(ll i = (a); i < (b); ++i) #define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rrep(i, a, b) for(ll i = (b); i --> (a); ) int scan(){ return getchar(); } void scan(int& a){ scanf("%d", &a); } void scan(unsigned& a){ scanf("%u", &a); } void scan(long long& a){ scanf("%lld", &a); } void scan(unsigned long long& a){ scanf("%llu", &a); } void scan(char& a){ do{ a = getchar(); }while(a == ' ' || a == '\n'); } void scan(float& a){ scanf("%f", &a); } void scan(double& a){ scanf("%lf", &a); } void scan(long double& a){ scanf("%Lf", &a); } void scan(vector& a){ for(unsigned i = 0; i < a.size(); i++) { int b; scan(b); a[i] = b; } } void scan(char a[]){ scanf("%s", a); } void scan(string& a){ cin >> a; } template void scan(vector&); template void scan(deque&); template void scan(array&); template void scan(pair&); template void scan(T(&)[size]); template void scan(vector& a){ for(auto& i : a) scan(i); } template void scan(deque& a){ for(auto& i : a) scan(i); } template void scan(array& a){ for(auto& i : a) scan(i); } template void scan(pair& p){ scan(p.first); scan(p.second); } template void scan(T (&a)[size]){ for(auto& i : a) scan(i); } template void scan(T& a){ cin >> a; } void in(){} template void in(Head& head, Tail&... tail){ scan(head); in(tail...); } void print(){ putchar(' '); } void print(bool a){ printf("%d", a); } void print(int a){ printf("%d", a); } void print(unsigned a){ printf("%u", a); } void print(long long a){ printf("%lld", a); } void print(unsigned long long a){ printf("%llu", a); } void print(char a){ printf("%c", a); } void print(char a[]){ printf("%s", a); } void print(float a){ printf("%.15f", a); } void print(double a){ printf("%.15f", a); } void print(long double a){ printf("%.15Lf", a); } void print(const string& a){ for(auto&& i : a) print(i); } template void print(const vector&); template void print(const array&); template void print(const pair& p); template void print(const T (&)[size]); template void print(const vector& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template void print(const deque& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template void print(const array& a){ print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ putchar(' '); print(*i); } } template void print(const pair& p){ print(p.first); putchar(' '); print(p.second); } template void print(const T (&a)[size]){ print(a[0]); for(auto i = a; ++i != end(a); ){ putchar(' '); print(*i); } } template void print(const T& a){ cout << a; } int out(){ putchar('\n'); return 0; } template int out(const T& t){ print(t); putchar('\n'); return 0; } template int out(const Head& head, const Tail&... tail){ print(head); putchar(' '); out(tail...); return 0; } #define LL(...) ll __VA_ARGS__; in(__VA_ARGS__) #define STR(...) string __VA_ARGS__; in(__VA_ARGS__) #define CHR(...) char __VA_ARGS__; in(__VA_ARGS__) #define DBL(...) double __VA_ARGS__; in(__VA_ARGS__) #define VEC(type,name,size) vector name(size); in(name) #define VV(type, name, h, w) vector> name(h, vector(w)); in(name) #define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/ #define pb push_back #define pf push_front #define fi first #define se second #define eb emplace_back #define endl '\n' #define SZ(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define debug(v) cout<<#v<<":";for(auto x:v){cout< Point; // Point typedef long long ll; typedef vector vl; typedef vectorvvl; typedef vectorvvvl; typedef vectorvvvvl; typedef vectorvvvvvl; typedef vectorvi; typedef vectorvvi; typedef vectorvvvi; typedef vectorvvvvi; typedef vectorvvvvvi; typedef pair P; #define __builtin_popcount __builtin_popcountll // typedef double D; template using minpq=priority_queue,greater>; // const ll MOD=1000000007LL; const ll MOD=998244353LL; using mint=modint998244353; // using mint=modint; // using mint=modint1000000007; // using mint=modint; typedef vector vm; typedef vector >vvm; typedef vector > >vvvm; //上下右左 vl dx={-1,1,0,0,1,1,-1,-1}; vl dy={0,-0,1,-1,-1,1,-1,1}; template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ll sum(const T& a){ return accumulate(all(a), 0LL); } template auto min(const T& a){ return *min_element(all(a)); } template auto max(const T& a){ return *max_element(all(a)); } //素因数分解O(√n) mapprime_factor(ll n){ mapres; for(ll i=2;i*i<=n;i++){ while(n%i==0){ res[i]++; n/=i; } } if(n!=1)res[n]=1; return res; } const ll MAX = 5000010;//5*10^6 long long fac[MAX], finv[MAX], inv[MAX]; //finvが階乗の逆元 // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //素数判定O(√n) bool is_prime(ll n){ for(ll i=2;i*i<=n;i++){ if(n%i==0)return false; } return n!=1; } //約数の列挙O(√n) vectordivisor(ll n){ vectorres; for(ll i=1;i*i<=n;i++){ if(n%i==0){ res.push_back(i); if(i != n/i) res.push_back(n/i); } } return res; } ll exp(ll n,ll r){ if(r==0)return 1; return n*exp(n,r-1); } ll factorial(int n){ if(n==0)return 1; return n*factorial(n-1); } template< typename T > struct Compress { vector< T > xs; Compress() = default; Compress(const vector< T > &vs) { add(vs); } Compress(const initializer_list< vector< T > > &vs) { for(auto &p : vs) add(p); } void add(const vector< T > &vs) { copy(begin(vs), end(vs), back_inserter(xs)); } void add(const T &x) { xs.emplace_back(x); } void build() { sort(begin(xs), end(xs)); xs.erase(unique(begin(xs), end(xs)), end(xs)); } vector< int > get(const vector< T > &vs) const { vector< int > ret; transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) { return lower_bound(begin(xs), end(xs), x) - begin(xs); }); return ret; } int get(const T &x) const { return lower_bound(begin(xs), end(xs), x) - begin(xs); } const T &operator[](int k) const { return xs[k]; } }; template void rotate90(ll &h,ll &w,vector>&vec){ vector>vec2(w,vector(h)); for(int i=0;i dist(a, b - 1); return dist(mt); } int operator()(int b) { // [0, b) return (*this)(0, b); } }; // 構文解析 template struct Parser{ bool error;// ヤバイ時trueに Parser():error(false){} // カッコ,数 T factor(string &s,int &p){ T res(3); if(p>s; ll k;cin>>k; Parser>pt; vm vec=pt.execute(s); // debug(vec); cout<