Pondo Tree Distance


You are given a tree with nn vertices and qq queries. Each query gives two vertices uu and vv. Output the number of edges on the unique path between uu and vv.

This is a follow-up to Pondo LCA II. Root the tree at vertex 11, then

dist(u,v)=depth[u]+depth[v]2depth[lca(u,v)]\mathrm{dist}(u, v) = \mathrm{depth}[u] + \mathrm{depth}[v] - 2 \cdot \mathrm{depth}[\mathrm{lca}(u, v)].

In particular, dist(u,u)=0\mathrm{dist}(u, u) = 0. Use an Euler tour to compute the lowest common ancestors.

Input

The first line contains two integers nn and qq.

Each of the next n1n - 1 lines contains two integers uu and vv, denoting an undirected edge between uu and vv.

Each of the next qq lines contains two integers uu and vv, the endpoints of one path.

Vertices are numbered 11 through nn. The edges form a tree.

Output

Print qq lines. The ii-th line should contain the distance between the two vertices of the ii-th query.

Constraints

  • 1n,q1051 \le n, q \le 10^5
  • 1u,vn1 \le u, v \le n

Example 1

Input 1
5 6
1 2
2 3
2 4
1 5
2 5
5 2
3 5
3 4
2 3
4 4
Output 1
2
2
3
2
1
0
Explanation

The tree looks like this:

Code 1
      1
     / \
    2   5
   / \
  3   4

Rooted at 11, the depths of vertices 1,2,3,4,51, 2, 3, 4, 5 are 0,1,2,2,10, 1, 2, 2, 1. Then dist(3,5)=2+120=3\mathrm{dist}(3, 5) = 2 + 1 - 2 \cdot 0 = 3, and dist(4,4)=0\mathrm{dist}(4, 4) = 0.

Example 2

Input 2
10 10
4 7
7 8
2 4
6 7
8 10
5 8
2 9
3 7
1 9
2 9
6 8
8 9
2 8
8 9
3 8
4 10
5 7
5 6
3 9
Output 2
1
2
4
3
4
2
3
2
3
4

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.