You are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight.
We will ask you to perfrom the following operation:
- u v : ask for how many different integers that represent the weight of nodes there are on the path from u to v.
Input
In the first line there are two integers N and M.(N<=40000,M<=100000)
In the second line there are N integers.The ith integer denotes the weight of the ith node.
In the next N-1 lines,each line contains two integers u v,which describes an edge (u,v).
In the next M lines,each line contains two integers u v,which means an operation asking for how many different integers that represent the weight of nodes there are on the path from u to v.
Output
For each operation,print its result.
Example
Input: 8 5
8 2 105 2 9 3 8 5 7 7 1 2 1 3 1 4 3 5 3 6 3 7 4 8
2 5
7 8
Output: 4
4
<p>You are given a tree with <strong>N</strong> nodes.The tree nodes are numbered from <strong>1</strong> to <strong>N</strong>.Each node has an integer weight.</p>
<p>We will ask you to perfrom the following operation:</p>
<ul>
<li><strong>u v k</strong> : ask for the kth minimum weight on the path from node <strong>u</strong> to node <strong>v</strong></li>
</ul>
<p> </p>
<h3>Input</h3>
<p>In the first line there are two integers <strong>N</strong> and <strong>M</strong>.(<strong>N,M</strong><=100000)</p>
<p>In the second line there are <strong>N</strong> integers.The ith integer denotes the weight of the ith node.</p>
<p>In the next <strong>N-1</strong> lines,each line contains two integers <strong>u</strong> <strong>v</strong>,which describes an edge (<strong>u</strong>,<strong>v</strong>).</p>
<p>In the next <strong>M</strong> lines,each line contains three integers <strong>u</strong> <strong>v</strong> <strong>k</strong>,which means an operation asking for the kth minimum weight on the path from node <strong>u</strong> to node <strong>v</strong>.</p>
<h3>Output</h3>
<p>For each operation,print its result.</p>
<h3>Example</h3>
<pre><strong>Input:</strong>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 320px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">8 5</div>8 5
105 2 9 3 8 5 7 7
1 2
1 3
1 4
3 5
3 6
3 7
4 8<br />2 5 1<br />2 5 2<br />2 5 3<br />2 5 4<br />7 8 2 </pre>
<pre><strong>Output:</strong>
2<br />8<br />9<br />105<br />7 </pre>