Exponentiation

시간 제한3초메모리 제한1024 MB

요약
모든 변수가 2023으로 시작하고 다른 변수를 지수로 하는 거듭제곱으로 갱신될 때, 실제 값을 계산하지 않고 두 변수의 대소를 판정한다.
난이도

보통10점 중 7점

유형
수학, 시뮬레이션, 정수론, 구현
정답자
아직 제출이 없습니다

문제

In her spare time, Zoe develops an online calculator. Unfortunately, the calculator was targeted by a denial-of-service attack last week. The attacker created a lot of integer variables, exponentiated them with each other, and tried to do a bunch of comparisons. The huge integers were too much for the server to handle, so it crashed. Before Zoe fixes the issue, she decides to actually perform the calculations that the attacker requested.

There are nn integer variables x_1,x_2,…,x_nx\_1, x\_2, \dots, x\_n. At the start, each variable is set to 20232023. You have to perform mm instructions of the following two types:

  • Operations, of the form "! ii jj", where i≠ji \neq j. This means that x_ix\_i gets set to x_ix_jx\_i^{x\_j}.
  • Queries, of the form "? ii jj", where i≠ji \neq j. This means that you should print '>' if x_ix\_i is greater than x_jx\_j, '=' if x_ix\_i is equal to x_jx\_j, and '<' if x_ix\_i is smaller than x_jx\_j.

Consider the first sample. After the 55 operations, the values of the variables are: \begin{align\*} x\_1&=\left({2023}^{2023}\right)^{{2023}^{2023}},& x\_2&=\left({2023}^{{2023}^{2023}}\right)^{2023},& x\_3&={2023},& x\_4&={2023}^{2023}. \end{align\*}

입력

The input consists of:

  • One line with two integers nn and mm (2≤n≤10002 \leq n \leq 1000, 1≤m≤10001 \leq m \leq 1000), the number of variables and the number of instructions.
  • mm lines, each containing a character cc (either '!' or '?') and two integers ii and jj (1≤i,j≤n1 \leq i, j \leq n, i≠ji \neq j), describing the instructions.

출력

For every query in the input, output its answer.

예제2

  1. 예제 1

    입력
    4 8
    ! 1 4
    ! 2 1
    ! 4 3
    ! 1 4
    ! 2 3
    ? 3 4
    ? 2 4
    ? 2 1
    
    예상 출력
    <
    >
    =
    
  2. 예제 2

    입력
    4 9
    ! 2 4
    ! 1 2
    ? 3 1
    ? 1 2
    ! 2 3
    ? 1 2
    ! 1 3
    ! 3 2
    ? 1 3
    
    예상 출력
    <
    >
    >
    <