Garage

Maintain a sequence under point updates, and for each range query count subarrays whose elements share a common divisor greater than 1.

Hard9Segment treeNumber theoryMathDynamic programmingNo attempts yetTime limit4sMemory limit256 MB

Problem

Slavko has been studying sequences of natural numbers. He calls a sequence interesting if the greatest common divisor of all its elements is greater than 1.

Yesterday he found a sequence of NN natural numbers in his garage. He was bored, so he decided to keep himself busy with simple queries. Each query is one of two types.

  1. Change the value at position XX of the sequence to VV.
  2. Count the interesting contiguous subarrays contained in the interval [L,R][L, R] of the sequence.

Input

The first line contains the number of elements NN and the number of queries QQ (1N,Q1051 \le N, Q \le 10^5).

The second line contains NN natural numbers AiA_i, the initial sequence (1Ai1091 \le A_i \le 10^9).

Each of the next QQ lines contains one query in the following form.

  • The first number on the line is 1 or 2 and gives the type of the query.
  • For a query of type 1, two numbers XX and VV follow (1XN1 \le X \le N, 1V1091 \le V \le 10^9).
  • For a query of type 2, the left and right boundaries LL and RR follow (1LRN1 \le L \le R \le N).

Output

For each query of type 2, print the number of interesting contiguous subarrays on its own line.

Hint

In the first example, the interval from position 2 to position 5 is (4, 3, 9, 1). The interesting contiguous subarrays inside it, marked with square brackets, are [4] 3 9 1, 4 [3] 9 1, 4 3 [9] 1, 4 [3 9] 1, so there are four of them.