100 #ABC209D. [ABC209D] Collision

[ABC209D] Collision

Score : 400400 points

Problem Statement

The Kingdom of Takahashi is made up of NN towns and N1N-1 roads, where the towns are numbered 11 through NN. The ii-th road (1iN1)(1 \leq i \leq N-1) connects Town aia_i and Town bib_i, so that you can get from every town to every town by using some roads. All the roads have the same length.

You will be given QQ queries. In the ii-th query (1iQ)(1 \leq i \leq Q), given integers cic_i and did_i, solve the following problem:

  • Takahashi is now at Town cic_i and Aoki is now at Town did_i. They will leave the towns simultaneously and start traveling at the same speed, Takahashi heading to Town did_i and Aoki heading to Town cic_i. Determine whether they will meet at a town or halfway along a road. Here, assume that both of them travel along the shortest paths, and the time it takes to pass towns is negligible.

Constraints

  • 2N1052 \leq N \leq 10^5
  • 1Q1051 \leq Q \leq 10^5
  • 1ai<biN(1iN1)1 \leq a_i < b_i \leq N\, (1 \leq i \leq N-1)
  • 1ci<diN(1iQ)1 \leq c_i < d_i \leq N\, (1 \leq i \leq Q)
  • All values in input are integers.
  • It is possible to get from every town to every town by using some roads.

Input

Input is given from Standard Input in the following format:

NN QQ

a1a_1 b1b_1

a2a_2 b2b_2

\hspace{0.6cm}\vdots

aN1a_{N-1} bN1b_{N-1}

c1c_1 d1d_1

c2c_2 d2d_2

\hspace{0.6cm}\vdots

cQc_Q dQd_Q

Output

Print QQ lines. The ii-th line (1iQ)(1 \leq i \leq Q) should contain Town if Takahashi and Aoki will meet at a town in the ii-th query, and Road if they meet halfway along a road in that query.

4 1
1 2
2 3
2 4
1 2
Road

In the first and only query, Takahashi and Aoki simultaneously leave Town 11 and Town 22, respectively, and they will meet halfway along the 11-st road, so we should print Road.

5 2
1 2
2 3
3 4
4 5
1 3
1 5
Town
Town

In the first query, Takahashi and Aoki simultaneously leave Town 11 and Town 33, respectively, and they will meet at Town 22, so we should print Town.

In the first query, Takahashi and Aoki simultaneously leave Town 11 and Town 55, respectively, and they will meet at Town 33, so we should print Town.

9 9
2 3
5 6
4 8
8 9
4 5
3 4
1 9
3 7
7 9
2 5
2 6
4 6
2 4
5 8
7 8
3 6
5 6
Town
Road
Town
Town
Town
Town
Road
Road
Road