There are $n$ purchase plans. The $i$-th plan is as follows:
- Spend $a_i$ to purchase one item;
- Spend $b_i$ to purchase two items.
The two options cannot be chosen simultaneously, and each plan can be executed at most once. Given $q$ operations:
1 p x y: $a_p \leftarrow x, b_p \leftarrow y$2 l r k: Only plans $i \in [l, r]$ can be executed. What is the minimum cost to purchase $k$ items?
Input
Two integers $n, q$ on the first line.
$n$ lines, each containing two integers $a_i, b_i$.
$q$ lines, each representing an operation as described above.
Output
For each query operation, output one integer per line.
Constraints
$1 \le n, q \le 1 \times 10^5, 1 \le a_i < b_i \le 10^9, 0 \le l \le r < n, 1 \le k \le 2(r - l + 1)$
Subtasks
| Subtask ID | Special Properties | Score |
|---|---|---|
| 1 | $1 \le n, q \le 14$ | 5 |
| 2 | $1 \le n, q \le 300$ | 5 |
| 3 | $1 \le n, q \le 2 \times 10^3$ | 15 |
| 4 | $1 \le n, q \le 1 \times 10^5, l = 0$, no type 1 operations | 15 |
| 5 | No type 1 operations | 10 |
| 6 | $1 \le n, q \le 8 \times 10^4$ | 20 |
| 7 | None | 30 |
Examples
Input 1
3 3 1 10 2 10 3 10 2 0 2 3 1 1 5 6 2 0 2 3
Output 1
6 7