#include using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000000000 int main(){ int N,Q; scanf("%d %d",&N,&Q); vector> childs(N,vector()); vector parent(N,0); for(int i=0;i num(N,0); for(int i=0;ichilds[parent[B]].size())swap(A,B); int p = parent[A]; int t = num[p]; for(int j=0;j