#include using namespace std; typedef pair P; typedef long long ll; typedef vector vi; typedef vector vll; // #define int long long #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 //2e9 #define LLINF 1000000000000000ll // 1e15 #define fi first #define sec second #define all(x) (x).begin(),(x).end() #define sq(x) ((x)*(x)) #define dmp(x) cerr << #x << ": " << x << endl; template void chmin(T& a,const T& b){if(a>b)a=b;} template void chmax(T& a,const T& b){if(a using MaxHeap = priority_queue; template using MinHeap = priority_queue,greater>; template vector vect(int len,T elem){ return vector(len,elem); } template ostream& operator << (ostream& os,const pair& p){ os << p.fi << ',' << p.sec; return os; } template istream& operator >> (istream& is,pair& p){ is >> p.fi >> p.sec; return is; } template ostream& operator << (ostream &os,const vector &vec){ for(int i=0;i istream& operator >> (istream &is,vector& vec){ for(int i=0;i> vec[i]; return is; } void fastio(){ cin.tie(0); ios::sync_with_stdio(0); cout< // if inv is needed, this shold be prime. struct ModInt{ ll val; ModInt():val(0ll){} ModInt(const ll& v):val(((v%MOD)+MOD)%MOD){} bool operator==(const ModInt& x)const{return val==x.val;} bool operator!=(const ModInt& x)const{return !(*this==x);} bool operator<(const ModInt& x)const{return val(const ModInt& x)const{return val>x.val;} bool operator>=(const ModInt& x)const{return !(*thisx);} ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;} ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;} ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;} ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;} ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;} ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;} friend istream& operator>>(istream&i,ModInt& x){ll v;i>>v;x=v;return i;} friend ostream& operator<<(ostream&o,const ModInt& x){o< ModInt pow(ModInt a,ll x){ ModInt res = ModInt(1ll); while(x){ if(x&1)res *= a; x >>= 1; a = a*a; } return res; } constexpr int MOD = 1e9+7; using mint = ModInt; vector inv,fac,facinv; // notice: 0C0 = 1 ModInt nCr(int n,int r){ assert(!(n int digit(T x){ int res = 0; while(x){ x /= T(10); res++; } return res; } } namespace DS{ template struct RangeSum{ vector vec; RangeSum(){} RangeSum(vector elems):vec(elems){ for(int i=1;ir)return T(0); if(l==0)return vec[r]; else return vec[r]-vec[l-1]; } }; template struct BIT{ int N; vector bit; BIT(int N):N(N){ bit = vector(N+1,T(0)); } void add(int i,T x){ i++; while(i<=N){ bit[i]+=x; i+=i&-i; } return; } T sum(int i){ i++; T res = T(0); while(i>0){ res+=bit[i]; i-=i&-i; } return res; } T sum(int l,int r){// [l,r] assert(l<=r); if(l==0)return sum(r); else return sum(r)-sum(l-1); } }; template struct SlideMin{ vector v; deque deq; SlideMin(vector &v):v(v){} void add(int id){ while(!deq.empty()&&v[deq.back()]>=v[id])deq.pop_back(); deq.push_back(id); } T get(int id){ // [id,added] while(!deq.empty()&&deq.front() struct SlideMax{ vector v; deque deq; SlideMax(vector &v):v(v){} void add(int id){ while(!deq.empty()&&v[deq.back()]<=v[id])deq.pop_back(); deq.push_back(id); } T get(int id){ // [id,added] while(!deq.empty()&&deq.front() vector> runLength(vector v){ vector> res; for(int i=0;i void compress(vector &v){ sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); } } int N; vector G[100100]; int deg[100100]; bool used[100100]; int cmp = 0; void dfs(int v){ used[v] = true; cmp++; for(int i=0;i> N; for(int i=0;i> u >> v; G[u].pb(v); G[v].pb(u); deg[u]++; deg[v]++; } vector cnt; memset(used,false,sizeof(used)); for(int i=0;i