D. Divisors

Time limit: 1.5sMemory limit: 256MBInput: Output:

You are given an array a=(a1,a2,…,an)a = (a_1, a_2, \dots, a_n) of nn non-negative integers. Let d(x)d(x) denote the number of positive divisors of xx. For example, d(6)=4d(6) = 4, since the positive divisors of 66 are 1,2,31, 2, 3, and 66. By convention, d(0)=0d(0) = 0.

You must process qq queries of the following three types:

  • 1 l r x — For every ii such that l≤i≤rl \le i \le r, replace aia_i with (aiORx)(a_i \mathbin{\mathrm{OR}} x).
  • 2 idx y — Replace aidxa_{\mathit{idx}} with (aidxANDy)(a_{\mathit{idx}} \mathbin{\mathrm{AND}} y).
  • 3 l r — Compute and output ∑i=lrd(ai)\sum_{i=l}^{r} d(a_i).

Here, OR\mathrm{OR} and AND\mathrm{AND} denote the bitwise OR and bitwise AND operations, respectively.

Input

The first line contains two integers nn (1≤n≤1051 \le n \le 10^5) and qq (1≤q≤1051 \le q \le 10^5) — the length of the array and the number of queries.

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0≤ai≤1060 \le a_i \le 10^6) — the initial elements of the array.

Each of the next qq lines describes a query and begins with an integer type∈{1,2,3}\mathit{type} \in \{1, 2, 3\}:

  • If type=1\mathit{type} = 1, three integers l,r,xl, r, x follow (1≤l≤r≤n1 \le l \le r \le n, 0≤x≤1060 \le x \le 10^6).
  • If type=2\mathit{type} = 2, two integers idx,y\mathit{idx}, y follow (1≤idx≤n1 \le \mathit{idx} \le n, 0≤y≤1060 \le y \le 10^6).
  • If type=3\mathit{type} = 3, two integers l,rl, r follow (1≤l≤r≤n1 \le l \le r \le n).

It is guaranteed that there is at least one query of type 33.

Output

For each query of type 33, output a single integer on a new line --- the sum of d(ai)d(a_i) over l≤i≤rl \le i \le r.

Example

stdin

5 4
4 5 6 7 8
3 1 5
1 1 3 2
2 4 3
3 1 5

stdout

15
16

Note

Initially, a=[4,5,6,7,8]a = [4, 5, 6, 7, 8], with divisor counts d(4)=3d(4) = 3, d(5)=2d(5) = 2, d(6)=4d(6) = 4, d(7)=2d(7) = 2, and d(8)=4d(8) = 4.

  • Query 1 (3 1 5): The sum over [1,5][1, 5] is 3+2+4+2+4=153 + 2 + 4 + 2 + 4 = 15.
  • Query 2 (1 1 3 2): a1=4OR2=6a_1 = 4 \mathbin{\mathrm{OR}} 2 = 6, a2=5OR2=7a_2 = 5 \mathbin{\mathrm{OR}} 2 = 7, a3=6OR2=6a_3 = 6 \mathbin{\mathrm{OR}} 2 = 6. The array becomes [6,7,6,7,8][6, 7, 6, 7, 8].
  • Query 3 (2 4 3): a4=7AND3=3a_4 = 7 \mathbin{\mathrm{AND}} 3 = 3. The array becomes [6,7,6,3,8][6, 7, 6, 3, 8].
  • Query 4 (3 1 5): The divisor counts are now 4,2,4,2,44, 2, 4, 2, 4, so the sum is 4+2+4+2+4=164 + 2 + 4 + 2 + 4 = 16.

Log In or Sign Up to be able to send submissions!