{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDSM(Data Structure Master) once learned about tree when he was preparing for NOIP(National Olympiad in Informatics in Provinces) in Senior High School. So when in Data Structure Class in College, he is always absent-minded about what the teacher says.\u003c/p\u003e\n\u003cp\u003eThe experienced and knowledgeable teacher had known about him even before the first class. However, she didn\u0027t wish an informatics genius would destroy himself with idleness. After she knew that he was so interested in ACM(ACM International Collegiate Programming Contest), she finally made a plan to teach him to work hard in class, for knowledge is infinite.\u003c/p\u003e\n\u003cp\u003eThis day, the teacher teaches about trees.\" A tree with $n$ nodes, can be defined as a graph with only one connected component and no cycle. So it has exactly $n-1$ edges...\" DSM is nearly asleep until he is questioned by teacher. \" I have known you are called Data Structure Master in Graph Theory, so here is a problem. \"\" A tree with $n$ nodes, which is numbered from $1$ to $n$. Edge between each two adjacent vertexes $u$ and $v$ has a value w, you\u0027re asked to answer the number of edge whose value is no more than $k$ during the path between $u$ and $v$.\"\" If you can\u0027t solve the problem during the break, we will call you DaShaMao(Foolish Idiot) later on.\"\u003c/p\u003e\n\u003cp\u003eThe problem seems quite easy for DSM. However, it can hardly be solved in a break. It\u0027s such a disgrace if DSM can\u0027t solve the problem. So during the break, he telephones you just for help. Can you save him for his dignity?\u003c/p\u003e\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eIn the first line there are two integers $n,m$, represent the number of vertexes on the tree and queries($2 \\le n \\le 10^5,1 \\le m \\le 10^5$)\u003c/p\u003e\n\u003cp\u003eThe next $n-1$ lines, each line contains three integers $u,v,w$, indicates there is an undirected edge between nodes $u$ and $v$ with value $w$. ($1 \\le u,v \\le n,1 \\le w \\le 10^9$)\u003c/p\u003e\n\u003cp\u003eThe next $m$ lines, each line contains three integers $u,v,k$ , be consistent with the problem given by the teacher above. $(1 \\le u,v \\le n,0 \\le k \\le 10^9)$\u003c/p\u003e\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eFor each query, just print a single line contains the number of edges which meet the condition.\u003c/p\u003e"}},{"title":"Sample 1","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 3\n1 3 2\n2 3 7\n1 3 0\n1 2 4\n1 2 7\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n1\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}},{"title":"Sample 2","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\u003e5 2\n1 2 1000000000\n1 3 1000000000\n2 4 1000000000\n3 5 1000000000\n2 3 1000000000\n4 5 1000000000\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cbr /\u003e"}}]}