Towns and Roads

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

There are nn towns and n1n - 1 bidirectional roads. Towns are numbered from 11 to nn, and roads are numbered from 11 to n1n - 1, respectively. Road ii connects town a_ia\_i and town b_ib\_i and has length d_id\_i.

At the beginning, all roads are open, and from any town, you can reach all other towns using one or more roads.

There is a robot, initially in town 11.

Your task is to process qq queries. Each query has one of the following three types:

  • 1 xx: move robot to town xx. At the time of this query, it is guaranteed that the town where robot is located and town xx are directly connected by one open road.
  • 2 yy: road yy is closed. At the time of this query, it is guaranteed that road yy is open.
  • 3 zz: road zz is opened again. At the time of this query, it is guaranteed that road zz is closed.

In addition, immediately after each query, print the list of towns that are farthest from the town where the robot currently is, if we consider only roads that are open after this query.

입력

The first line of the input contains one integer nn, the number of towns (1n21051 \le n \le 2 \cdot 10^5).

The ii-th of the following n1n - 1 lines contains three integers a_ia\_i, b_ib\_i and d_id\_i: the numbers of cities connected by ii-th road and the length of this road, respectively (1a_i,b_in1 \le a\_i, b\_i \le n, a_ib_ia\_i \ne b\_i, 1d_i1061 \le d\_i \le 10^6). It is guaranteed that, from any town, you can reach all other towns using one or more roads.

The next line contains one integer qq (1q21051 \le q \le 2 \cdot 10^5). 

Then qq queries follow. Each query is given on a separate line and has one of the three forms described above.

출력

Print qq lines: the ii-th line should contain the answer to the ii-th query.

For each query, start the line with an integer c_ic\_i: the number of towns that are farthest from the town where the robot is after the ii-th query. Then print c_ic\_i integers on the same line: the numbers of these towns in ascending order.

It is guaranteed that, in each test given to your solution, the sum of all c_ic\_i in the correct answer will not exceed 41054 \cdot 10^5.