#P1483. 序列变换

序列变换

Description

Given a sequence of nn integers a1,a2,,ana_1, a_2, \ldots , a_n, you need to perform the following operations:

  1. Input format 1 x y, which means add yy to all akxa_{k x} (where kk is a positive integer and kxnk x \le n).
  2. Input format 2 j, which means output aja_j.

Specifically, for operation 2, when j=0j = 0, output 00.

Input Format

The first line contains two integers n,mn, m, meaning there are nn numbers and mm operations.
The second line contains nn integers a1,a2,,ana_1, a_2, \ldots , a_n.
Then follow mm lines, each describing one of the mm operations.

Output Format

Output several lines, each corresponding to one operation 2.

5 4
6 9 9 8 1 
2 4
1 2 5
1 3 1
2 4

8
13

Hint

For 40%40 \% of the testdata, n100n \le 100.
For 100%100 \% of the testdata, 1n1061 \le n \le {10}^6, 1m1051 \le m \le {10}^5, ai106|a_i| \le {10}^6, y106|y| \le {10}^6, 1xn1 \le x\le n, 0jn0\le j \le n, and the number of operation 2 is at most 104{10}^4.

Translated by ChatGPT 5