dfs(v) {
  color[v] = 1
  for (a, i) in query[v]  {
    if (color[a] != 0)
      answer[i] =
      lca[get(a)]
  }
  for v --> x {
    dfs(x)
    int a = get(v)
    int b = get(x)
    int z = lca[a]
    if (size[a] > size[b])
      swap(a, b)
    size[b] += size[a]
    p[a] = b
    lca[b] = z
  }
}