Efficient Data Structure

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

Elly has two sequences a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n and b_1,b_2,,b_nb\_1, b\_2, \ldots, b\_n. She would like to perform the following operations:

  • 1 xx yy, change the value of a_xa\_x to yy.
  • 2 xx yy, change the value of b_xb\_x to yy.
  • 3 xx, find the value of c_xc\_x, where c_0=0c\_0=0, c_i=max(c_i1+b_i,a_i) for 1ixc\_i=\max(c\_{i-1}+b\_i,a\_i) \text{ for } 1 \le i \le x.

Implement an efficient data structure to process those operations.

입력

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains two integers nn and mm , which are the length of the two sequences and the number of operations. The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n. The third line contains nn integers b_1,b_2,,b_nb\_1, b\_2, \ldots, b\_n. Each of the last mm lines contains a query.

출력

For each query of type 3, output an integer denoting the value of c_xc\_x.

제한

  • 1n,m2×1051 \leq n, m \leq 2 \times 10^5
  • 109a_i,b_i,y109-10^9 \leq a\_i, b\_i, y \leq 10^9
  • 1xn1 \leq x \leq n
  • The sum of nn and the sum of mm do not exceed 2×1062 \times 10^6.