#P1924B. Space Harbour

    ID: 10339 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>data structuresimplementationmathsortings*2100

Space Harbour

Description

There are nn points numbered 11 to nn on a straight line. Initially, there are mm harbours. The ii-th harbour is at point XiX_i and has a value ViV_i. It is guaranteed that there are harbours at the points 11 and nn. There is exactly one ship on each of the nn points. The cost of moving a ship from its current location to the next harbour is the product of the value of the nearest harbour to its left and the distance from the nearest harbour to its right. Specifically, if a ship is already at a harbour, the cost of moving it to the next harbour is 00.

Additionally, there are qq queries, each of which is either of the following 22 types:

  • 11 xx vv — Add a harbour at point xx with value vv. It is guaranteed that before adding the harbour, there is no harbour at point xx.
  • 22 ll rr — Print the sum of the cost of moving all ships at points from ll to rr to their next harbours. Note that you just need to calculate the cost of moving the ships but not actually move them.

The first line contains three integers nn, mm, and qq (2mn31052 \le m \le n \le 3 \cdot 10^5, 1q31051 \le q \le 3 \cdot 10^5) — the number of points, harbours, and queries, respectively.

The second line contains mm distinct integers X1,X2,,Xm(1Xin)X_1, X_2, \ldots, X_m(1 \le X_i \le n) — the position at which the ii-th harbour is located.

The third line contains mm integers V1,V2,,Vm(1Vi107)V_1, V_2, \ldots, V_m(1 \le V_i \le 10^7) — the value of the ii-th harbour.

Each of the next qq lines contains three integers. The first integer is tt (1t21\le t \le 2) — type of query. If t=1t=1, then the next two integers are xx and vv (2xn12 \le x \le n - 1, 1v1071 \le v \le 10^7) — first-type query. If t=2t=2, then the next two integers are ll and rr (1lrn1 \le l \le r \le n) — second-type query.

It is guaranteed that there is at least one second-type query.

For every second-type query, print one integer in a new line — answer to this query.

Input

The first line contains three integers nn, mm, and qq (2mn31052 \le m \le n \le 3 \cdot 10^5, 1q31051 \le q \le 3 \cdot 10^5) — the number of points, harbours, and queries, respectively.

The second line contains mm distinct integers X1,X2,,Xm(1Xin)X_1, X_2, \ldots, X_m(1 \le X_i \le n) — the position at which the ii-th harbour is located.

The third line contains mm integers V1,V2,,Vm(1Vi107)V_1, V_2, \ldots, V_m(1 \le V_i \le 10^7) — the value of the ii-th harbour.

Each of the next qq lines contains three integers. The first integer is tt (1t21\le t \le 2) — type of query. If t=1t=1, then the next two integers are xx and vv (2xn12 \le x \le n - 1, 1v1071 \le v \le 10^7) — first-type query. If t=2t=2, then the next two integers are ll and rr (1lrn1 \le l \le r \le n) — second-type query.

It is guaranteed that there is at least one second-type query.

Output

For every second-type query, print one integer in a new line — answer to this query.

Sample Input 1

8 3 4
1 3 8
3 24 10
2 2 5
1 5 15
2 5 5
2 7 8

Sample Output 1

171
0
15

Note

For the first type 22 query, the cost for ships at positions 22, 33, 44 and 55 are 3(3×1)3(3 \times 1), 00, 96(24×4)96(24 \times 4) and 72(24×3)72(24 \times 3) respectively.

For the second type 22 query, since the ship at position 55 is already at a harbour, so the cost is 00.

For the third type 22 query, the cost for ships at position 77 and 88 are 15(15×1)15(15 \times 1) and 00 respectively.