#P5574. Colorful Tree

    ID: 4447 远端评测题 12000ms 128MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2015ACM/ICPC亚洲区上海站-重现赛(感谢华东理工)

Colorful Tree

Problem Description

As we all know, frogs live on trees and have different colors.

$N$ frogs are living on a tree. The tree consists of $N$ nodes with node $1$ as the root, each frog occupies a node.

Frogs have different colors, and can change colors as they like. On each day, all the frogs living on a certain sub-tree will change its color. The root of the sub-tree, and the color they change to, is given to the frog king.

As the frog king, sometimes he may wonder, how many different colors of frog are there in a certain sub-tree? It turns to you to solve the problem for the king.

Input

First line contains an integer $T$, which indicates the number of test cases.

Every test case begins with an integers $N$, which is the numbers of nodes in the tree.

The following $N - 1$ lines describe the edges of the tree, and every line is formatted as '$u\ v$', which indicates there is a edge between node $u$ and node $v$.

The next line contains $N$ intergers, $c_1$, $c_2$, $\cdots$, $c_N$, and $c_i$ is the initial color of the frog living at node $i$.

Then a number $M$ follows, which indicates the number of queries, and following $M$ lines describe the quries as format bellow.



$\cdot$ $1 \leq T \leq 100$.

$\cdot$ For 85% data, $1 \leq N, M \leq 1000$.

$\cdot$ for 100% data, $1 \leq N, M \leq 10^5$.

$\cdot$ for every node, $1 \leq c_i \leq N$.

$\cdot$ for every edge, $1 \leq u, v \leq N$.

$\cdot$ for every query, $1 \leq u, c \leq N$.

Output

For every test case, you should output "Case #x:" first,
where $x$ indicates the case number and counts from $1$.

Then for each query operation, output the number of different colors.

1 5 1 2 1 3 2 5 2 4 1 2 3 4 5 6 1 1 0 4 2 1 1 1 2 0 2 3 1 2
Case #1: 5 4 2 1