CF1791F.Range Update Point Query

传统题 时间 2000 ms 内存 256 MiB 8 尝试 3 已通过 1 标签

Range Update Point Query

Given an array a1,a2,,ana_1, a_2, \dots, a_n, you need to handle a total of qq updates and queries of two types:

  • 11 ll rr — for each index ii with lirl \leq i \leq r, update the value of aia_i to the sum of the digits of aia_i.
  • 22 xx — output axa_x.

Input

The first line of the input contains an integer tt (1t10001 \leq t \leq 1000) — the number of testcases.

The first line of each test case contains two integers nn and qq (1n,q21051 \le n, q \le 2 \cdot 10^5) — the size of the array and the number of queries, respectively.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9).

The next qq lines of each test case are of two forms:

  • 11 ll rr (1lrn1 \leq l \leq r \leq n) — it means, for each index ii with lirl \leq i \leq r, you should update the value of aia_i to the sum of its digits.
  • 22 xx (1xn1 \leq x \leq n) — it means you should output axa_x.

There is at least one query of the second type.

The sum of nn over all test cases does not exceed 21052 \cdot 10^5.

The sum of qq over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output the answers of queries of the second type, in the order they are given.

Note

In the first test case, the following process occurs:

  • Initially, a=[1,420,69,1434,2023]a = [1, 420, 69, 1434, 2023].
  • The operation is performed for l=2l=2, r=3r=3, yielding [1,6,15,1434,2023][1, \color{red}{6}, \color{red}{15}, 1434, 2023].
  • We are queried for x=2x=2, x=3x=3, and x=4x=4, and output 66, 1515, and 14341434.
  • The operation is performed for l=2l=2, r=5r=5, yielding $[1, \color{red}{6}, \color{red}{6}, \color{red}{12}, \color{red}{7}]$.
  • We are queried for x=1x=1, x=3x=3, and x=5x=5, and output 11, 66, and 77.

Samples

3
5 8
1 420 69 1434 2023
1 2 3
2 2
2 3
2 4
1 2 5
2 1
2 3
2 5
2 3
9999 1000
1 1 2
2 1
2 2
1 1
1
2 1
6
15
1434
1
6
7
36
1
1

在线编程 IDE

建议全屏模式获得最佳体验