using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; var h=new int[s[1]][]; Uf uf=new Uf(s[0]+1); for(int i = 0;i{g[x]=k++;}); StringBuilder sb=new StringBuilder(); for(int i = 0;i0){a+=bit[n];n-=n&-n;} return a; } public void Clear(){bit=new long[n+1];} } } public class Uf{ public class Nd{ public int n; public Nd ne; public Nd(int n){this.n=n;} } private int[] arr,hi; public Nd[] f,l; public int all; public Uf(int n){ arr=new int[n]; hi=new int[n]; f=new Nd[n]; l=new Nd[n]; all=n; for(int i=0;i fu){ var e=f[a]; for(int j = 0;j(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i