There is an undirected graph G with n vertices. It has an interesting property: if we treat multiple edges as one, the graph G will become a tree. Alice and Bob invented the following game:
Children like the game very much so they have played it q times. Now they are wondering who would win in each game if they were playing optimally. Help them find it out!
The first line of input contains two integers n and q: the number of vertices in graph G and the number of games played by Alice and Bob (2≤n≤105, 1≤q≤105).
The next n−1 lines contain the description of graph G. Each line consists of three integers a, b and c (1≤a,b≤n, 1≤c≤109) which means there are exactly c edges between vertices a and b. It is guaranteed that, if we change all c to 1, the graph G will become a tree with n vertices.
The next q lines describe the games. Each of these lines contains two integers S and T: the parameters of the game (1≤S,T≤n, S=T).
For each game, print 1 if Alice wins, and print 2 otherwise. Separate the answers with line breaks.