Problems

# Range Variation Query

# Range Variation Query

The sequence **a _{n}** is given with the formula:

**a**=

_{n}**n**

^{2}**mod 12345**+

**n**.

^{3}mod 23456You need to answer the next queries a lot of times:

- find the difference between the maximum and the minimum element among the values
**a**,_{i}**a**, ...,_{i+1}**a**;_{j} - assign to the element
**a**the value of_{i}**j**.

**Input**

The first line contains the number of queries **k** (**k** ≤ **100 000**). Each of the next **k** lines contains one query. The **i**-th query contains the numbers **x _{i}**,

**y**.

_{i} If **x _{i}** >

**0**, find the difference between the maximum and the minimum element among the values of

**a**...

_{xi}**a**. It is known that

_{yi}**1**≤

**x**≤

_{i}**y**≤

_{i}**100 000**.

If **x _{i}** <

**0**, assign to the element

**a**the value of

_{-xi}**y**. It is known that

_{i}**-100 000**≤

**x**≤

_{i}**-1**and |

**y**| ≤

_{i}**100 000**.

** Output**

For each query of the first type print in a separate line the difference between the maximum and the minimum element on a given segment.

Input example #1

7 1 3 2 4 -2 -100 1 5 8 9 -3 -101 2 3

Output example #1

34 68 250 234 1