Under construction

Still being built. Things may change

Relocation

Time limit1sMemory limit1024 MB

Summary
Each company has a coordinate that can be updated, and each query asks for the absolute difference between two companies' coordinates.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

In the faraway country of Lineland, tech companies keep appearing. Every week, new companies are founded, merged, acquired, or shut down. Software engineers looking for new jobs in Lineland often cannot even find the offices of the companies where they are interviewing.

To solve this, you are building a new tech company. The product is simple: using deep neural blockchains in the cloud, your app finds the distance between any two tech companies in Lineland. This is useful because companies change offices all the time, and keeping up with those moves is hard. By centralizing this information, your company will make the world a better place.

Lineland is organized around a single line, so the location of each company is a single coordinate. The distance between two companies is the distance between their two coordinates.

Your job is to handle two kinds of requests sent to the company's flagship app. One kind updates the address of a company. The other asks for the shortest distance between two companies.

Input

The first line has two positive integers NN and QQ, separated by a space. NN is the number of companies the app tracks (2≤N≤100 0002 \le N \le 100\,000), and QQ is the number of requests to process (1≤Q≤100 0001 \le Q \le 100\,000).

The next line has NN integers XiX_i (1≤Xi≤1091 \le X_i \le 10^9), the initial locations of the companies in order from i=1i=1 to i=Ni=N.

Each of the next QQ lines has three integers in one of the following forms:

  • 1 C X: company CC moves to location XX.
  • 2 A B: a query for the distance between companies AA and BB.

It is guaranteed that 1≤A,B,C≤N1 \le A, B, C \le N and 1≤X≤1091 \le X \le 10^9. Two companies may share the same location. There is at least one query of type 2.

Output

For each query of type 2, print the distance between companies AA and BB on its own line.

Hint

In the first query, company 2 moves to location 10. The app is then asked for the distance between company 4 and company 5, which is 3. The next query asks for the distance between companies 1 and 3, which is also 3. Several more updates and queries follow.

Examples1

  1. Example 1

    Input
    5 10
    5 2 8 1 4
    1 2 10
    2 4 5
    2 1 3
    1 4 3
    2 1 5
    2 5 2
    1 4 1
    2 2 4
    1 3 15
    2 4 1
    
    Expected output
    3
    3
    1
    6
    9
    4