Magical Tree Query

You are given a rooted tree (a connected graph with no cycles) with n vertices. The vertices are numbered from 1 to n, the root is the vertex number 1. Each vertex i has an integer color Ci.


This is a companion discussion topic for the original entry at https://toph.co/p/magical-tree-query