시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
10 초 512 MB 1 1 1 100.000%

## 문제

Consider a prime number $p$.

All operations below will be performed in the multiplicative group modulo $p$.

Given an array of size $n$, process $q$ queries of two types:

• "1 $l$ $r$ $x$": multiply all elements of the segment $[l; r]$ by $x$;
• "2 $l$ $r$": find the order of the subgroup generated by the set of elements from the segment $[l; r]$.

To revise some of the definitions, see the notes below.

## 입력

In the first line of input, there are three integers $p$, $n$, $q$: the prime number, the size of the array and the number of queries ($2 \le p < 10^{9}$, $p$ is prime, $1 \le n \le 10^{5}$, $1 \le q \le 10^{5}$).

The second line of input contains the initial array $a$ of size $n$ ($1 \le a_{i} < p$).

The next $q$ lines describe the queries.

A query of the first type is described as "1 $l$ $r$ $x$": multiply all elements of the segment $[l; r]$ by $x$ ($1 \le l \le r \le n$, $1 \le x < p$).

A query of the second type is described as "2 $l$ $r$": find the order of the subgroup generated by the set of elements from the segment $[l; r]$ ($1 \le l \le r \le n$).

## 출력

For each query of the second type, print the answer to it on a separate line.

## 예제 입력 1

17 3 7
10 16 2
2 2 3
2 1 2
2 2 2
1 1 2 3
2 1 1
2 3 3
2 1 3


## 예제 출력 1

8
16
2
4
8
16


## 노트

In this section, we will give definitions for all terms from group theory which appear in the statement. All the definitions are conventional, so feel free to skip the section if you are familiar with the basics of group theory.

A group is a set with associative binary operation. The group is closed under its operation: for any two elements $a$ and $b$ of the group, $a \circ b$ is also an element of this group, where $\circ$ is the binary operation. There exists the identity element (equivalent of $1$ for multiplication), and for every element there exists an inverse.

A multiplicative group modulo prime number $p$ is defined as follows. The elements of the group are non-zero remainders modulo $p$: that is, $1, 2, \ldots, p-1$. The operation is multiplication modulo $p$. It is easy to see that it is a group.

A subgroup is a subset $H$ of group $G$ which itself is a group for the same operation as in $G$: in particular, it is closed under the binary operation.

A subgroup generated by a set: for any subset $S \subseteq G$, $\langle S \rangle$ is the smallest subgroup $G$ which contains $S$. This subgroup is unique.

The order of the group is the number of elements in it.