{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given a tree with \u003ci\u003eN\u003c/i\u003e nodes. The tree’s nodes are numbered 1 through \u003ci\u003eN\u003c/i\u003e and its edges are numbered 1 through \u003ci\u003eN\u003c/i\u003e − 1. Each edge is associated with a weight. Then you are to execute a series of instructions on the tree. The instructions can be one of the following forms:\u003c/p\u003e\u003ctable border\u003d\"1\" style\u003d\"border-collapse: collapse\"\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eCHANGE\u003c/code\u003e \u003ci\u003ei\u003c/i\u003e \u003ci\u003ev\u003c/i\u003e\u003c/td\u003e\u003ctd\u003eChange the weight of the \u003ci\u003ei\u003c/i\u003eth edge to \u003ci\u003ev\u003c/i\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eNEGATE\u003c/code\u003e \u003ci\u003ea\u003c/i\u003e \u003ci\u003eb\u003c/i\u003e\u003c/td\u003e\u003ctd\u003eNegate the weight of every edge on the path from \u003ci\u003ea\u003c/i\u003e to \u003ci\u003eb\u003c/i\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003ccode\u003eQUERY\u003c/code\u003e \u003ci\u003ea\u003c/i\u003e \u003ci\u003eb\u003c/i\u003e\u003c/td\u003e\u003ctd\u003eFind the maximum weight of edges on the path from \u003ci\u003ea\u003c/i\u003e to \u003ci\u003eb\u003c/i\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe input contains multiple test cases. The first line of input contains an integer \u003ci\u003et\u003c/i\u003e (\u003ci\u003et\u003c/i\u003e ≤ 20), the number of test cases. Then follow the test cases.\u003c/p\u003e\u003cp\u003eEach test case is preceded by an empty line. The first nonempty line of its contains \u003ci\u003eN\u003c/i\u003e (\u003ci\u003eN\u003c/i\u003e ≤ 10,000). The next \u003ci\u003eN\u003c/i\u003e − 1 lines each contains three integers \u003ci\u003ea\u003c/i\u003e, \u003ci\u003eb\u003c/i\u003e and c, describing an edge connecting nodes \u003ci\u003ea\u003c/i\u003e and \u003ci\u003eb\u003c/i\u003e with weight \u003ci\u003ec\u003c/i\u003e. The edges are numbered in the order they appear in the input. Below them are the instructions, each sticking to the specification above. A lines with the word “\u003ccode\u003eDONE\u003c/code\u003e” ends the test case.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eFor each “\u003ccode\u003eQUERY\u003c/code\u003e” instruction, output the result on a separate line.\u003c/p\u003e\u003c/span\u003e"}},{"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\n\r\n3\r\n1 2 1\r\n2 3 2\r\nQUERY 1 2\r\nCHANGE 1 3\r\nQUERY 1 2\r\nDONE\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}