Lexicographic Comparison
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

a and p are permutaions of length n. Initiallly, for all . A is a sequence of permutations such that and for all and .

There are three types of operations, where x and y are positive integers:
  1.  swap_a x y: swap a_x and a_y, where , ;
  2.  swap_p x y: swap p_x and p_y, where , ;
  3.  cmp x y: compare A_x with A_y lexicographically.
For each operation 3, output the relationship between A_x and A_y. A permutation s is lexicographically samller than a permutation t if and only if there exists an index i such that and for all .

输入描述:

There are multiple test cases. The first line of input contains an integer T(), the number of test cases. For each test case:

The first line contains an integer n and q (, ) - the length of the permutations and the number of operations.

Each of the following q lines contains one string f and two integers x and y representing an operation. f is one of ”swap_a”, ”swap_p” and ”cmp”. If f is one of ”swap_a” and ”swap_p”, , . If f is ”cmp”, , .

It is guaranteed that the sum of n and the sum of q over all tests do not exceed .

输出描述:

For each test case:

For each query, output ”<” if A_x is lexicographically smaller than A_y; output ”>” if A_x is lexicographically greater than A_y (i.e., A_y is lexicographically smaller than A_x); output ”=” if .
示例1

输入

复制
2
5 5
cmp 1 2
swap_p 1 2
cmp 1 2
swap_a 1 2
cmp 1 2
1 1
swap_a 1 1

输出

复制
=
<
>