This is an interactive problem.
When preparing to New Year Eve, Queen Amidala always checks her electric garland to ensure it works. The garland consist of n lamps which are numbered from 1 to n; there are (n - 1) pairs of them which are allowed to be connected with wires to form a special structure. Each wire in the structure connects exactly two different lamps, and all the lamps are connected together with the wires.
However, the garland is so huge that this year, the Queen decided not to build the whole structure at once. However, she still needs to check each wire. So, she will connect some of the wires, then check if electric current can pass from some lamps to some others, then disconnect some of the connected wires, connect other ones and so on. More formally, the Queen will perform a sequence of operations. Each operation will be one of the following:
The Queen was almost starting to check the garland, but she realized that not all her tests will be meaningful because some pairs of lamps will be disconnected at the time she checks them, and the current will not pass even if the garland is in fact working. She asked Anakin Skywalker to help in checking her plan of checking the garland. Anakin is sure that it's boring to proceed all the operations manually, so he asked you to write a program which will process all three types of operations described above; for each test operation, the program must answer whether the two lamps are connected by wires of not. Anakin shouldn't disgrace himself in Amidala's eyes, so don't let him down!
At start, your program will be given an integer n (1 ≤ n ≤ 100 000). After that, you have to process queries one by one. Each query will be entered on a separate line in one of the following forms:
There will be no more than 300 000 queries.
It is guaranteed that the queries will always follow the garland's structure, and each possible wire will be connected and disconnected exactly once.
Initially, all possible wires are disconnected.
3
C 1 2
C 2 3
T 1 2
D 2 3
D 1 2
T 1 2
E
YES
NO
Name |
---|