QOJ.ac

QOJ

时间限制: 3 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#18693. Yet Another Modify and Query Problem

统计

You are given an sequence $A$ of length $n$. Let $f(x,y)=[x\leq y]$, here $[st]=1$ if statement $st$ is true, otherwise $[st]=0$. The characteristic sequence of $A$ is another sequence $B$ of length $n-1$, where $B_i=f(A_i,A_{i+1})$. For example, the characteristic sequence of $1,3,3,1,2$ is $1,1,0,1$.

There are $q$ queries in the following format.

  • $1\ x\ v$, which means that you should change $A_x$ into $v$, notice that the characteristic sequence will also change.
  • $2\ l\ r\ v$, which means that you should find the smallest $i\in [l,r]$ such that if you replace $A_i$ with $v$, the characteristic sequence will not change, or output $-1$ if there are no such $i$. Notice that this query will not change the sequence.

Please, give the answer to all the queries of type $2$.

Input

The first line contains two integers $n,q$ ($3\leq n\leq 5\times 10^5, 1\leq q\leq 5\times 10^5$), denoting the length of the sequence and the number of queries.

The following line contains $n$ integers, the $i$-th of which denotes $A_i$ ($1\leq A_i\leq 10^9$).

Each of the following $q$ lines contains one query, in the format given above. If the type of the query is $1$, then it is guaranteed that $1\leq x\leq n, 1\leq v\leq 10^9$. If the type of the query is $2$, then it is guaranteed that $1\leq l\leq r\leq n, 1\leq v\leq 10^9$.

Output

For each query of type $2$, output one line, denoting the answer to the query.

Examples

Input 1

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

Output 1

-1
2
3

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.