{"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\u003cp\u003eAda the Ladybug lives on a bush. A typical bush consists of some fruits connected with branches. Ada wants to travel between some fruits. Problem is that each edge can stand only some \u003cstrong\u003eX\u003csub\u003ei\u003c/sub\u003e\u003c/strong\u003e weight (so if some creature with more weight would like to travel over the edge, it would break and the creature would fall of the bush).\u003c/p\u003e\r\n\u003cp\u003eAda wants to make several travels so she asks you (for each such travel) to how many distinct fruits she can get?\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of each test-case will contain three integers \u003cstrong\u003e2 ≤ N ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/strong\u003e, the number of fruits, \u003cstrong\u003e 1 ≤ M ≤ 2*10\u003csup\u003e5\u003c/sup\u003e\u003c/strong\u003e, the number of edges and \u003cstrong\u003e1 ≤ Q ≤ 3*10\u003csup\u003e5\u003c/sup\u003e\u003c/strong\u003e, the number of queries.\u003c/p\u003e\r\n\u003cp\u003eThe next \u003cstrong\u003eM\u003c/strong\u003e lines will contain three integers \u003cstrong\u003e0 ≤ a, b \u0026lt; N (a ≠ b)\u003c/strong\u003e, the fruits which are connected by and edge and \u003cstrong\u003e1 ≤ X\u003csub\u003ei\u003c/sub\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/strong\u003e.\u003c/p\u003e\r\n\u003cp\u003eThe next \u003cstrong\u003eQ\u003c/strong\u003e lines will contain two integers \u003cstrong\u003e0 ≤ a \u0026lt; N\u003c/strong\u003e, the fruit Ada starts in and \u003cstrong\u003e1 ≤ Y ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/strong\u003e, her actual weight.\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eNOTE\u003c/strong\u003e Multiedges are allowed.\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each query, output the number of fruits Ada can get to.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e4 4 3\r\n1 2 4\r\n2 3 3\r\n3 0 4\r\n0 1 3\r\n1 3\r\n1 4\r\n1 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n2\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e8 10 8\r\n1 3 3\r\n1 2 2 \r\n3 5 1\r\n3 4 3\r\n2 4 7\r\n5 6 2\r\n4 6 8\r\n4 7 3\r\n7 0 1\r\n6 0 4\r\n1 3\r\n1 4\r\n0 5\r\n6 6\r\n6 1\r\n2 3\r\n0 4\r\n5 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\r\n1\r\n1\r\n3\r\n8\r\n7\r\n4\r\n8\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c/div\u003e"}}]}