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; static List[] li; static int[] h; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; int n=s[0],m=n-1; li=new List[n+1]; h=new int[n+1]; for(int i=1;i<=n;i++){li[i]=new List();} for(int i=0;i[] li; private readonly int[] at,ix,de,l,h; private readonly int[][] g; private int f=0; public Alca(List[] li,bool bo,int[] h){ int n=li.Length,z=(n<<1)-1,m=z; this.li=li; this.h=h; at=new int[z]; ix=new int[n]; de=new int[n]; if(bo){Fu1(1,0);} else{ for(int i = 1;i>1]+1; } for(int i=1,k=1;ib){a^=b;b^=a;a^=b;} int p=l[b-a]; return at[de[at[g[p][a]]](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