You are the supervisor of a super-secret government operation, where coordination is key, and everything will go wrong otherwise. You are in charge of workers, numbered from to , each of which have the ability to directly communicate with some other workers. These worker relations can be viewed as a tree (connected undirected acyclic graph), where each node represents one of the workers, and each edge represents one of the direct two-sided communication channels between two workers. This relation tree has a special property, namely that, in order to maximize work efficiency, each worker has at most direct communication channels with any other workers. This way, each of the workers can directly or indirectly communicate with each other, via a series of direct communications.

Task
You, as the supervisor, have to handle events of the following types:
- As a result of a mutual agreement, worker and worker decide to switch roles in order to prevent burnout. More exactly, they will switch places in the network. As a result, worker will now work with worker 's former direct colleagues, and worker will now work with worker 's former direct colleagues.
- You know that, in order to complete the next phase of the operation, you need at least workers working in tandem. As such, in order to maximize the efficiency of the operation, you want to use as little workers as possible. Realizing that this might be a tideous task, you settle for finding the minimal prefix of workers , such that each worker in can collaborate with any other worker in , communicating only through workers in , thus being able to complete the phase successfully. More formally, we want to find the minimum , such that the induced subgraph made up of nodes in the range is connected.
Input data
The input file consists of:
- a line containing integer .
- lines, the -th of which consisting of the integers and , representing an edge between nodes and .
- a line containing integer .
- lines, of the format , or , depending on the type of the event.
Output data
The output file must contain the answer for each event of type , on a single line each.
Constraints and clarifications
- .
- .
- for all edges, and events of type .
- for all events of type .
- An induced subgraph of graph is a graph , such that , and , it holds that .|
| # | Score | Constraints |
|---|---|---|
| 1 | 0 | Examples |
| 2 | 10 | . |
| 3 | 15 | , there are no updates. |
| 4 | 20 | , the tree is a line of the form . |
| 5 | 22 | |
| 6 | 33 | No additional restrictions |
Example
stdin
11
1 2
1 3
2 10
2 11
3 4
3 5
3 6
5 7
6 8
6 9
12
2 1
2 5
2 3
1 3 5
2 1
2 2
1 1 11
2 1
2 2
2 3
2 4
2 5
stdout
1
5
3
1
2
1
2
11
11
11
Explanation
For simplicity, we'll denote the induced subgraph made up of nodes as .
For the first three events of type , the tree looks like this.

As can be observed, is connected for all in . As such, for all queries, the minimum is .
For the next two events of type , the tree looks like this.

For , the minimal prefix subgraph is , which is connected.
For , the minimal prefix subgraph is , which is connected.
For the next five events of type , the tree looks like this.

For , the minimal prefix subgraph is , which is connected.
For , the minimal prefix subgraph is , which is connected.
For , the minimal prefix subgraph is , which is connected.
For , the minimal prefix subgraph is , which is connected.
For , the minimal prefix subgraph is , which is connected.