{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv align\u003d\"center\"\u003e\u003cimg src\u003d\"https://upload.wikimedia.org/wikipedia/commons/2/21/Grace_Murray_Hopper%2C_in_her_office_in_Washington_DC%2C_1978%2C_%C2%A9Lynn_Gilbert.jpg\" width\u003d\"300\"\u003e\u003c/div\u003e\n\n\u003cp\u003eGrace Brewster Hopper (December 9, 1906 – January 1, 1992) was an American computer scientist, mathematician, and United States Navy rear admiral. One of the first programmers of the Harvard Mark I computer, she was a pioneer of computer programming. Hopper was the first to devise the theory of machine-independent programming languages, and the FLOW-MATIC programming language she created using this theory was later extended by others to create COBOL, an early high-level programming language still in use today.\u003c/p\u003e\n\n\u003cp\u003e In her early programming days, Grace Hopper solved lots of programming problems involving trees and graphs. In one of those problems a weighted tree is given. The programmer has to find the distance between two given nodes. \u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains the number of nodes of the tree \u003ci\u003en\u003c/i\u003e (1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 50000). The nodes are numbered from 0 to \u003ci\u003en\u003c/i\u003e\u0026nbsp;–\u0026nbsp;1.\nEach of the next \u003ci\u003en\u003c/i\u003e\u0026nbsp;–\u0026nbsp;1 lines contains three integers \n\u003ci\u003eu\u003c/i\u003e, \u003ci\u003ev\u003c/i\u003e, \u003ci\u003ew\u003c/i\u003e, which correspond to an edge\nwith weight \u003ci\u003ew\u003c/i\u003e (0 ≤ \u003ci\u003ew\u003c/i\u003e ≤ 1000) connecting nodes \u003ci\u003eu\u003c/i\u003e and \u003ci\u003ev\u003c/i\u003e.\nThe next line contains the number of queries \u003ci\u003em\u003c/i\u003e (1\u0026nbsp;≤\u0026nbsp;\u003ci\u003em\u003c/i\u003e\u0026nbsp;≤\u0026nbsp;75000).\nIn each of the next \u003ci\u003em\u003c/i\u003e lines there are two integers.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eFor each query, output the distance between the nodes with the given numbers.\u003c/div\u003e\u003c/div\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\u003e3\n1 0 1\n2 0 1\n3\n0 1\n0 2\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n1\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}