#include typedef uint32_t uint; typedef uint64_t u64; typedef int64_t i64; typedef long double f128; using namespace std; templateclass modint{ public: u64 val; constexpr modint(const u64 x=0) noexcept:val(x%mod){} constexpr u64 &value() noexcept{ return val; } constexpr const u64 &value() const noexcept{ return val; } constexpr modint operator+(const modint rhs) const noexcept{ return modint(*this)+=rhs; } constexpr modint operator-(const modint rhs) const noexcept{ return modint(*this)-=rhs; } constexpr modint operator*(const modint rhs) const noexcept{ return modint(*this)*=rhs; } constexpr modint operator/(const modint rhs) const noexcept{ return modint(*this)/=rhs; } constexpr modint operator^(const u64 rhs) const noexcept{ return modint(*this)^=rhs; } constexpr bool operator==(const modint rhs) const noexcept{ return (*this).val==rhs.val; } constexpr bool operator!=(const modint rhs) const noexcept{ return (*this).val!=rhs.val; } constexpr modint &operator+=(const modint rhs) noexcept{ val+=rhs.val; if(val>=mod){ val-=mod; } return *this; } constexpr modint &operator-=(const modint rhs) noexcept{ if(val>=1; } return *this; } constexpr modint &operator^=(u64 rhs) noexcept{ modint a=(*this); (*this)=1; while(rhs){ if(rhs&1){ (*this)*=a; } a*=a; rhs>>=1; } return *this; } friend constexpr ostream &operator<<(ostream &os,const modint &x) noexcept{ return os<<(x.val); } friend constexpr istream &operator>>(istream &is,modint &x) noexcept{ u64 t; is>>t; x=t; return is; } }; void scan(){} template void scan(T& n,Args&... args){ cin>>n; scan(args...); } template void scanall(T start,T end){ T now=start; for(;now!=end;++now){ cin>>(*now); } } void print(){} template void print(T n,Args... args){ cout< void println(T n){ cout< void println(T n,Args... args){ cout< void printall(T start,T end){ if(start!=end){ T now=start; cout<<(*now); ++now; for(;now!=end;++now){ cout<<' '<<(*now); } } cout< vector div_enum(T n){ vector res; for(T i=1;i*i<=n;++i){ if(n%i!=0){ continue; } res.push_back(i); if(i*i!=n){ res.push_back(n/i); } } sort(res.begin(),res.end()); return res; } template vector> prime_fact(T n){ vector> res; for(T i=2;i*i<=n;++i){ if(n%i!=0){ continue; } T ex=0; while(n%i==0){ n/=i; ex+=1; } res.push_back({i,ex}); } if(n!=1){ res.push_back({n,1}); } return res; } template T power(T a,U n) { T res=1; while(n){ res*=(n&1)?a:1; a*=a; n>>=1; } return res; } template struct combination { vector fact; combination(const int Max):fact(Max+1,1){ for(int i=2;i<=Max;++i){ fact[i]=fact[i-1]*(T)i; } } template T nCk(U n,U k){ if(n struct RSQ{ int N; vector bit; RSQ(int size):N(size+1),bit(size+1){}; void add(int a,T x){ a+=1; for(int i=a;i0;i-=(i&(-i))){ res+=bit[i]; } return res; } }; template struct RmQ{ const T INF=numeric_limits::max(); int n=-1; vector dat; RmQ(int n_):dat(n_*4,INF) { int x=1; while(x struct unionfind{ T Max; vector par,siz; unionfind(T Max_):Max(Max_),par(Max_),siz(Max_,1){ for(T i=0;i parset(){ vector res(0); for(T i=0;i