//sub-BOF //#define _AOJ_ /*vvv> zzzzzI .---. zzuzuI .vgggg&,. +++++= dAC:|I .WbbWo JMM9^```?TMB` ..&gNNg,. gggggggJ, qgggggggg] (&&&&&&&&[ c+OA&J, (&&&&&&+J, .cJeAA&-. (&&&&&&&&x .&AA&=-. +++++= dTqk|I Xpbpbp JM#` (M#^ ?MMp MM| +TMN. JMF ' |yk ` dVY 7Vk, Vy XV cVf ?Y! JM V$ ` +++++= dcf:|I Xppppp dMN .MM+ .MM MM| MM] JMMMMMM+ |@tqkoh) ,y0 (V$ yyyyyyyV7 VV JMWyZWr TWVVVVW&, ++++++ d7qk|0 Xppppp ^HMN, _.db WMm, .MMF MM| ..MM` JMF . |yk .WV&. .XW' yy 4yn. jyn +. JM #S `++++` ?ZZZX= ?WWWW= -THMMMMH9^ (TMMMMM9! MMMMMMM"" JMMMMMMMME |UU. ?TUUUUY= UU. (UU- ^7TUUUV7! JUUUUUUUU 7TUNKO*/ #pragma region template #pragma region basic #pragma GCC optimize ("O3")//#pragma GCC optimize ("fast-math") #pragma GCC target ("avx2") #include "bits/stdc++.h" using namespace std; typedef long long lint; typedef long double ld; typedef string cs; #pragma endregion #pragma region rep #define _vcppunko4(tuple) _getname4 tuple #define _getname4(_1,_2,_3,_4,name,...) name #define _getname3(_1,_2,_3,name,...) name #define _trep2(tuple) _rep2 tuple #define _trep3(tuple) _rep3 tuple #define _trep4(tuple) _rep4 tuple #define _rep1(n) for(lint i=0;i=0;--i) #define _rrep2(i,n) for(lint i=n-1;i>=0;--i) #define _rrep3(i,a,b) for(lint i=b-1;i>=a;--i) #define _rrep4(i,a,b,c) for(lint i=a+(b-a-1)/c*c;i>=a;i-=c) #define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__)) #define per(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_rrep1))((__VA_ARGS__)) #define each(c) for(auto &e:c) #pragma endregion #pragma region io template istream& operator>>(istream& is,vector& vec); template istream& operator>>(istream& is,array& vec); template istream& operator>>(istream& is,pair& p); template ostream& operator<<(ostream& os,vector& vec); template ostream& operator<<(ostream& os,pair& p); template istream& operator>>(istream& is,vector& vec){ for(T& x: vec) is>>x;return is; } template istream& operator>>(istream& is,pair& p){ is>>p.first;is>>p.second;return is; } template ostream& operator<<(ostream& os,pair& p){ os< ostream& operator<<(ostream& os,vector& vec){ os< ostream& operator<<(ostream& os,deque& deq){ os< HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); inline void in(){ SetConsoleTextAttribute(hConsole,10); } template inline void in(Head&& head,Tail&&... tail){ SetConsoleTextAttribute(hConsole,15); cin>>head;in(move(tail)...); } #else inline void in(){} template inline void in(Head&& head,Tail&&... tail){ cin>>head;in(move(tail)...); } #endif inline bool out(){ return(cout<<'\n',0); } template inline bool out(T t){ return(cout< inline bool out(Head head,Tail... tail){ cout< inline void alloc(T &c,lint s){ rep(c.size())c[i].resize(s); } #define alc alloc #pragma endregion #pragma region TA #define lin(...) lint __VA_ARGS__;in(__VA_ARGS__) #define stin(...) string __VA_ARGS__;in(__VA_ARGS__) #define vin(type,name,size) vector name(size);in(name) #define vvin(type,name,h,...) vector>name(h,vector(__VA_ARGS__));in(name) #define all(v) v.begin(),v.end() #define pb push_back #define fi e.first #define se e.second #define YES(c) cout<<((c)?"YES\n":"NO\n"),0 #define Yes(c) cout<<((c)?"Yes\n":"No\n"),0 #define POSSIBLE(c) cout<<((c)?"POSSIBLE\n":"IMPOSSIBLE\n"),0 #define Possible(c) cout<<((c)?"Possible\n":"Impossible\n"),0 #define o(p) cout< inline constexpr bool chmin(T &mn,const T &cnt){ if(mn>cnt){ mn=cnt;return 1; } else return 0; } template inline constexpr bool chmax(T &mx,const T &cnt){ if(mx #define fn(ty1,ty2,ex) [](ty1 a,ty2 b){ return(ex); } #define lfn(ex) [](lint a,lint b){ return(ex); } #pragma endregion #pragma region other #ifdef __ENV_TQK__ #define deb(...) out(__VA_ARGS__) #define dsp(ex) sp(ex) #define dno(ex) no(ex) #else #define deb(...) 0 #define dsp(ex) 0 #define dno(ex) 0 #endif struct Fastio{ Fastio(){ cin.tie(0),cout.tie(0); ios::sync_with_stdio(0); cout< md_tmp class mint{ using u64=uint_fast64_t; public: u64 a; constexpr mint(const u64 x=0) noexcept: a(x%md){} constexpr u64 &value() noexcept{ return a; } constexpr const u64 &value() const noexcept{ return a; } constexpr mint operator+(const mint rhs) const noexcept{ return mint(*this)+=rhs; } constexpr mint operator-(const mint rhs) const noexcept{ return mint(*this)-=rhs; } constexpr mint operator*(const mint rhs) const noexcept{ return mint(*this)*=rhs; } constexpr mint operator^(const lint rhs) const noexcept{ return mint(*this)^=rhs; } constexpr mint operator/(const mint rhs) const noexcept{ return mint(*this)/=rhs; } constexpr mint &operator+=(const mint rhs) noexcept{ a+=rhs.a; if(a>=md)a-=md; return *this; } constexpr mint &operator-=(const mint rhs) noexcept{ if(aa; while(exp){ if(exp&1)*this*=base; base*=base; exp>>=1; } return *this; } constexpr mint &operator/=(const mint rhs) noexcept{ a=(*this*(rhs^(md-2))).a; return *this; } }; md_tmp istream& operator>>(istream& os,mint& m){ os>>m.a,m.a%=md; return os; } md_tmp ostream& operator<<(ostream& os,const mint& m){ return os< ncr(lint n,lint r){ if(n(0); mintncr_res=1,ncr_div=1; rep(r)ncr_res*=(n-i),ncr_div*=(r-i); return ncr_res/ncr_div; } #ifndef _AOJ_ mint<> operator""m(const unsigned long long n){ return mint<>(n); } mint<998244353> operator""m9(const unsigned long long n){ return mint<998244353>(n); } mint<1000003> operator""m3(const unsigned long long n){ return mint<1000003>(n); } #endif #pragma endregion #pragma region P class P{ public:lint f,s; P(lint a,lint b):f(a),s(b){}; P():f(0),s(0){}; }; istream& operator>>(istream& os,P& p){ os>>p.f>>p.s;return os; } constexpr bool operator<(const P& l,const P& r){ return(l.f-r.f?l.f(const P& l,const P& r){ return(l.f-r.f?l.f>r.f:l.s>r.s); } constexpr bool operator<=(const P& l,const P& r){ return!(l.f-r.f?l.f>r.f:l.s>r.s); } constexpr bool operator>=(const P& l,const P& r){ return!(l.f-r.f?l.f