{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eAs we all know, frogs live on trees and have different colors.\u003cbr\u003e\u003cbr\u003e$N$ frogs are living on a tree. The tree consists of $N$ nodes with node $1$ as the root, each frog occupies a node.\u003cbr\u003e\u003cbr\u003eFrogs 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.\u003cbr\u003e\u003cbr\u003eAs 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.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line contains an integer $T$, which indicates the number of test cases.\u003cbr\u003e\u003cbr\u003eEvery test case begins with an integers $N$, which is the numbers of nodes in the tree.\u003cbr\u003e\u003cbr\u003eThe following $N - 1$ lines describe the edges of the tree, and every line is formatted as \u0027$u\\ v$\u0027, which indicates there is a edge between node $u$ and node $v$.\u003cbr\u003e\u003cbr\u003eThe 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$.\u003cbr\u003e\u003cbr\u003eThen a number $M$ follows, which indicates the number of queries, and following $M$ lines describe the quries as format bellow.\u003cbr\u003e\u003cbr\u003e\u003ccenter\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/a70546caaa3bc3f6f889fd5eb2c8b972?v\u003d1715685832\"\u003e\u003c/center\u003e\u003cbr\u003e\u003cbr\u003e$\\cdot$ $1 \\leq T \\leq 100$.\u003cbr\u003e\u003cbr\u003e$\\cdot$ For 85% data, $1 \\leq N, M \\leq 1000$.\u003cbr\u003e\u003cbr\u003e$\\cdot$ for 100% data, $1 \\leq N, M \\leq 10^5$.\u003cbr\u003e\u003cbr\u003e$\\cdot$ for every node, $1 \\leq c_i \\leq N$.\u003cbr\u003e\u003cbr\u003e$\\cdot$ for every edge, $1 \\leq u, v \\leq N$.\u003cbr\u003e\u003cbr\u003e$\\cdot$ for every query, $1 \\leq u, c \\leq N$.\u003cbr\u003e\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For every test case, you should output \"\u003cb\u003eCase #x:\u003c/b\u003e\" first,\u003cbr\u003ewhere $x$ indicates the case number and counts from $1$.\u003cbr\u003e\u003cbr\u003eThen for each query operation, output the number of different colors."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n5\r\n1 2\r\n1 3\r\n2 5\r\n2 4\r\n1 2 3 4 5\r\n6\r\n1 1\r\n0 4 2\r\n1 1\r\n1 2\r\n0 2 3\r\n1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n5\r\n4\r\n2\r\n1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}