There are $n$ flower pots in a row, numbered from $1$ to $n$. Along the row, you can place watering machines. Each watering machine is characterized by its position $x$ (an integer between $1$ and $n$) and its direction: left or right.
All watering machines share the same watering range $L$ (a non-negative integer).
- A watering machine at position $x$ pointing to the right waters all pots with indices in the segment $[x, x + L]$.
- A watering machine at position $x$ pointing to the left waters all pots with indices in the segment $[x - L, x]$.
Only pots with indices between $1$ and $n$ exist.
Initially, there are no watering machines. You need to process $q$ operations of two types:
- Insert a watering machine. An operation of the form "$1\ d\ x$" inserts a new watering machine at position $x$. If $d = 0$, the watering machine points to the left. If $d = 1$, the watering machine points to the right. Multiple watering machines may be placed at the same position. Operations are given in chronological order, and there are no deletions.
- Range query. An operation of the form "$2\ \ell\ r$" asks the following question: Consider the current set of watering machines. Suppose all watering machines have the same range $L$. Find the smallest integer $L \ge 0$ such that every pot with index in the segment $[\ell, r]$ is watered by at least one watering machine. Note that watering machines outside the interval $[\ell, r]$ may help water pots inside $[\ell, r]$. If there is no integer $L$ that makes all pots in $[\ell, r]$ watered (no matter how large $L$ is), you must output $-1$ for this query.
Input
The first line contains two integers, $n$ and $q$ ($1 \le n, q \le 3 \cdot 10^5$), representing the number of pots and the number of operations.
Each of the next $q$ lines describes one operation in the order they must be processed:
- "$1\ d\ x$": insert a watering machine at position $x$ with direction $d$ ($d \in \{0, 1\}$, $1 \le x \le n$). Here, $d = 0$ means the watering machine points to the left, and $d = 1$ means it points to the right.
- "$2\ \ell\ r$": query the minimal range $L$ for the segment $[\ell, r]$ ($1 \le \ell \le r \le n$).
Output
For each query of the form "$2\ \ell\ r$", output a single line with one integer:
- the minimal integer $L \ge 0$ such that every pot in $[\ell, r]$ is watered, or
- $-1$ if it is impossible.
Examples
Input 1
10 11 1 0 6 2 5 8 1 1 3 2 9 10 2 3 9 1 1 8 2 1 9 2 1 8 1 0 4 2 3 7 2 2 9
Output 1
-1 7 6 5 5 4 4