namespace tree { int son[ONE], size[ONE], top[ONE], fa[ONE], Dep[ONE];
voiddfs1(int u, int father) { size[u] = 1; fa[u] = father; Dep[u] = Dep[father] + 1; for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father) continue; dfs1(v, u); size[u] += v; if(size[son[u]] < size[v]) son[u] = v; } }
voiddfs2(int u, int father) { if(int v = son[u]) top[v] = top[u], dfs2(v, u); for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father || v == son[u]) continue; dfs2(top[v] = v, u); } }
intLCA(int u, int v) { while(top[u] != top[v]) { int &x = Dep[top[u]] > Dep[top[v]] ? u : v; x = fa[top[x]]; } return Dep[u] < Dep[v] ? u : v; } }
voiddfs_f(int u, int father) { f[u] = 1; for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father) continue; dfs_f(v, u); f[u] = (f[u] + f[v] + 1) % MOD; } }
voiddfs_g(int u, int father) { int res = 0; for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father) continue; res = (res + 1 + f[v]) % MOD; }