{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Five hundred years later, the number of dragon balls will increase unexpectedly, so it\u0027s too difficult for Monkey King(WuKong) to gather all of the dragon balls together. \n \u003cbr\u003e \n \u003ccenter\u003e \n \u003cimg style\u003d\"max-width:100%;\" SRC\u003d\"CDN_BASE_URL/4a6544a4139251ff34655ebaaf261a73?v\u003d1533879693\"\u003e \n \u003c/center\u003e \n \u003cbr\u003eHis country has N cities and there are exactly N dragon balls in the world. At first, for the ith dragon ball, the sacred dragon will puts it in the ith city. Through long years, some cities\u0027 dragon ball(s) would be transported to other cities. To save physical strength WuKong plans to take Flying Nimbus Cloud, a magical flying cloud to gather dragon balls. \n \u003cbr\u003eEvery time WuKong will collect the information of one dragon ball, he will ask you the information of that ball. You must tell him which city the ball is located and how many dragon balls are there in that city, you also need to tell him how many times the ball has been transported so far. \n\u003c/div\u003e\n\u003cbr\u003e有标号为1到n的n个龙珠,分别放在对应标号为1到n的n个城市里。\n\u003cbr\u003e下面有两种操作:\n\u003cbr\u003eT A B表示把A龙珠所在城市的所有龙珠都转移到B龙珠所在的城市中\n\u003cbr\u003eQ A 表示查询A,需要知道A龙珠现在所在的城市,A所在的城市有几颗龙珠,A转移到这个城市移动了多少次,分别输出3个整数,表示上述信息。\n"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input is a single positive integer T(0 \u0026lt; T \u0026lt;\u003d 100). \n\u003cbr\u003eFor each case, the first line contains two integers: N and Q (2 \u0026lt; N \u0026lt;\u003d 10000 , 2 \u0026lt; Q \u0026lt;\u003d 10000). \n\u003cbr\u003eEach of the following Q lines contains either a fact or a question as the follow format: \n\u003cbr\u003e\u0026nbsp;\u0026nbsp;T A B : All the dragon balls which are in the same city with A have been transported to the city the Bth ball in. You can assume that the two cities are different. \n\u003cbr\u003e\u0026nbsp;\u0026nbsp;Q A : WuKong want to know X (the id of the city Ath ball is in), Y (the count of balls in Xth city) and Z (the tranporting times of the Ath ball). (1 \u0026lt;\u003d A, B \u0026lt;\u003d N)\n\u003cbr\u003e第一行一个整数T表示测试数据组数T∈[0,100]\n\u003cbr\u003e对于每一组测试数据,第一行包含两个整数N,Q∈[2,10000]\n\u003cbr\u003e接下来Q行,每行包含如下的操作或询问:T A B或Q A,如题目描述所示。\n"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output the test case number formated as sample output. Then for each query, output a line with three integers X Y Z saparated by a blank space.\n\u003cbr\u003e对于每一组测试数据,先输出一行Case x:(x表示测试数据标号,从1开始),然后对于每一个询问,输出一行三个数表示答案,用空格隔开"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n3 3\nT 1 2\nT 3 2\nQ 2\n3 4\nT 1 2\nQ 1\nT 1 3\nQ 1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eCase 1:\n2 3 0\nCase 2:\n2 2 1\n3 3 2\u003c/pre\u003e"}}]}