{"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\"\u003eThere is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,that person is your subordinate, and all his subordinates are your subordinates as well. If you are nobody\u0027s boss, then you have no subordinates,the employee who has no immediate boss is the leader of whole company.So it means the N employees form a tree.\u003cbr\u003e\u003cbr\u003eThe company usually assigns some tasks to some employees to finish.When a task is assigned to someone,He/She will assigned it to all his/her subordinates.In other words,the person and all his/her subordinates received a task in the same time. Furthermore,whenever a employee received a task,he/she will stop the current task(if he/she has) and start the new one.\u003cbr\u003e\u003cbr\u003eWrite a program that will help in figuring out some employee’s current task after the company assign some tasks to some employee.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single positive integer T( T \u0026lt;\u003d 10 ), indicates the number of test cases.\u003cbr\u003e\u003cbr\u003eFor each test case:\u003cbr\u003e\u003cbr\u003eThe first line contains an integer N (N ≤ 50,000) , which is the number of the employees.\u003cbr\u003e\u003cbr\u003eThe following N - 1 lines each contain two integers u and v, which means the employee v is the immediate boss of employee u(1\u0026lt;\u003du,v\u0026lt;\u003dN).\u003cbr\u003e\u003cbr\u003eThe next line contains an integer M (M ≤ 50,000).\u003cbr\u003e\u003cbr\u003eThe following M lines each contain a message which is either\u003cbr\u003e\u003cbr\u003e\"C x\" which means an inquiry for the current task of employee x\u003cbr\u003e\u003cbr\u003eor\u003cbr\u003e\u003cbr\u003e\"T x y\"which means the company assign task y to employee x.\u003cbr\u003e\u003cbr\u003e(1\u0026lt;\u003dx\u0026lt;\u003dN,0\u0026lt;\u003dy\u0026lt;\u003d10^9)"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print the test case number (beginning with 1) in the first line and then for every inquiry, output the correspond answer per line."}},{"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\n4 3 \r\n3 2 \r\n1 3 \r\n5 2 \r\n5 \r\nC 3 \r\nT 2 1\r\n C 3 \r\nT 3 2 \r\nC 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n-1 \r\n1 \r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}