QOJ.ac

QOJ

Time Limit: 0.7 s Memory Limit: 256 MB Total points: 100

#9034. Heaven's Lost Property

Statistics

Ikaros has given you a sequence $a$ of length $n$.

You need to perform $m$ operations of two types:

  1. Change all values in the sequence equal to $x$ to $y$.
  2. Find a position $i$ such that $a_i=x$ and a position $j$ such that $a_j=y$ that minimize $|i-j|$, and output $|i-j|$.

Input

The first line contains two integers $n$ and $m$.

The next line contains $n$ integers, representing the sequence $a$.

The following $m$ lines each contain three integers $opt, x, y$.

If $opt$ is $1$, it means to change all values in the sequence equal to $x$ to $y$.

If $opt$ is $2$, it means to find a position $i$ such that $a_i=x$ and a position $j$ such that $a_j=y$ that minimize $|i-j|$, and output $|i-j|$. If no such positions can be found, output Ikaros.

This problem is forced online. Each $x$ and $y$ must be XORed with the answer to the previous query. If the output was Ikaros or if it is the first query, the previous answer is $0$.

There are $50$ test cases in total, and it is guaranteed that $n=m$.

Output

For each operation of type $2$, output a single integer representing the answer on a new line.

If it is impossible to find $i$ and $j$ satisfying the conditions, output Ikaros.

Examples

Input 1

5 5
1 2 2 4 4
2 3 3
2 2 4
1 3 2
1 5 5
2 2 5

Output 1

Ikaros
1
1

Subtasks

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477 (partially uploaded)

For $100\%$ of the data, all values are in the range $[1, 10^5]$, and the values in each operation do not exceed $n$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.