Operations

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given a sequence of nn integers a1,a2,,ana_1, a_2, \dots, a_n, where every element lies in the range [0,k1][0, k-1]. Perform mm operations of the following two kinds on this sequence.

  1. Report the range sum ac+ac+1++ada_c + a_{c+1} + \dots + a_d.
  2. Replace every aia_i with cidc \le i \le d by (ai+l)modk(a_i + l) \bmod k.

Input

The first line contains three integers nn, kk, and mm (1n1000001 \le n \le 100000, 1k101 \le k \le 10, 1m1000001 \le m \le 100000). The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n describing the sequence (0aik10 \le a_i \le k-1).

Each of the next mm lines describes one operation. Each line begins with an integer zz giving the operation type. If z=1z = 1, it is a range-sum query and is followed by two integers cc and dd. If z=2z = 2, it is a range-update operation and is followed by three integers cc, dd, and ll (1cdn1 \le c \le d \le n, 0lk10 \le l \le k-1).

Output

For each range-sum operation, print the computed result on its own line.