{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003ch3\u003eProblem description\u003c/h3\u003e\r\n\r\n\u003cp\u003e\r\nFarmer John has N barren pastures (2 \u0026lt;\u003d N \u0026lt;\u003d 100,000) connected by N-1 bidirectional roads, such that there is exactly one path between any two pastures. \u0026nbsp;Bessie, a cow who loves her grazing time, often complains about how there is no grass on the roads between pastures. \u0026nbsp;Farmer John loves Bessie very much, and today he is finally going to plant grass on the\u0026nbsp;roads. \u0026nbsp;He will do so using a procedure consisting of M steps (1 \u0026lt;\u003d M \u0026lt;\u003d\u0026nbsp;100,000).\r\n\u003c/p\u003e\r\n\r\n\u003cp\u003eAt each step one of two things will happen:\u003c/p\u003e\r\n\u003cul\u003e\r\n \u003cli\u003eFJ will choose two pastures, and plant a patch of grass along each road in\u0026nbsp;between the two pastures, or,\u003c/li\u003e\r\n \u003cli\u003eBessie will ask about how many patches of grass on a particular road, and Farmer John must answer her question.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eFarmer John is a very poor counter -- help him answer Bessie\u0027s questions!\u003c/p\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003e* Line 1: Two space-separated integers N and M\u003c/p\u003e\r\n\u003cp\u003e* Lines 2..N: Two space-separated integers describing the endpoints of\u0026nbsp;a road.\u003c/p\u003e\r\n\u003cp\u003e* Lines N+1..N+M: Line i+1 describes step i. The first character of\u0026nbsp;the line is either P or Q, which describes whether or not FJ\u0026nbsp;is planting grass or simply querying. This is followed by two\u0026nbsp;space-separated integers A_i and B_i (1 \u0026lt;\u003d A_i, B_i \u0026lt;\u003d N)\u0026nbsp;which describe FJ\u0027s action or query.\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003e* Lines 1..???: Each line has the answer to a query, appearing in the\u0026nbsp;same order as the queries appear in the input.\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003ch4\u003eSAMPLE INPUT\u003c/h4\u003e\r\n\u003cpre\u003e4 6\r\n1 4\r\n2 4\r\n3 4\r\nP 2 3\r\nP 1 3\r\nQ 3 4\r\nP 1 4\r\nQ 2 4\r\nQ 1 4\u003c/pre\u003e\r\n\r\n\u003ch4\u003eSAMPLE OUTPUT\u003c/h4\u003e\r\n\u003cpre\u003e2\r\n1\r\n2\u003c/pre\u003e\r\n\r\n\u003cp\u003e\u003cb\u003e[ Edited by EB ]\u003c/b\u003e\u003c/p\u003e\r\n\u003cp\u003e\u003cb\u003eWarning:\u003c/b\u003e Some input files are broken.\u003c/p\u003e\n\u003c/div\u003e"}}]}