B. Order Maintenance Structure
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

You should implement a list that allows the following operations:

  • < x — Given x not in the list, insert x in the beginning of the list.
  • I x y — Given y not in the list and x in the list, insert y after the element x.
  • D x — Given x in the list, remove element x from the list.
  • O x y — Given x and y in the list, return YES if x comes before y in the list, or NO otherwise.

Initially, the list is empty.

All queries are online, that means you should flush the output before reading the input for the following query. Use fflush(stdout) for C/C++.

Input

In the first line an integer Q, the number of queries. Each of the next Q lines has a query, in the format given in the statement.

Limits

  • 1 ≤ Q ≤ 2·105
  • For all queries, x and y will be between 1 and 2·105.
Output

For each query of type O, print YES or NO, the value returned. Don't forget to flush the output.

Examples
Input
5
< 1
< 2
O 1 2
I 2 10
O 10 1
Output
NO
YES
Input
10
< 1
I 1 2
I 1 3
I 1 4
I 1 5
I 1 6
I 1 7
O 7 6
O 3 7
O 6 4
Output
YES
NO
YES