410435: GYM104021 G Pot!!

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Pot!!time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Little Q is very sleepy, and he really needs some impenetrable hard problems coffee to make him awake. At this time, Little L brings a pot to Little Q, and he states the pot as follows.

For a prime number $$$p$$$, if $$$p^m | n$$$ and $$$p^{m+1}\not | n$$$, we say $$$\text{pot}_p(n)=m$$$.

The pot is very special that it can make everyone awake immediately.

Now Little L provides $$$n~(1 \le n \le 10^5)$$$ integers $$$a_1, a_2, \cdots, a_n$$$ to Little Q, each of which is $$$1$$$ initially. After that, Little L shows $$$2$$$ types of queries:

  • MULTIPLY l r x : For every $$$i \in [l,r]$$$ ($$$1\le l\le r\le n$$$), multiply $$$a_i$$$ by $$$x$$$ ($$$2 \le x \le 10$$$).
  • MAX l r : Calculate the value of $$$$$$\max_{l\le i\le r} \left\{ \max_{p|a_i} \left\{ \text{pot}_p (a_i) \right\} \right\}~(1 \le l \le r \le n),$$$$$$ where $$$p$$$ is prime.

Now you need to perform $$$q~(1 \le q \le 10^5)$$$ queries of these two types of queries described above.

If you perform a "MULTIPLY" query, you don't need to output anything.

If you perform a "MAX" query, you need to output a line like "ANSWER y", where $$$y$$$ the value you've calculated.

Input

The first line contains two integers $$$n~(1 \le n \le 10^5)$$$ and $$$q~(1 \le q \le 10^5)$$$, the number of integers and the number of queries.

Each of the next $$$q$$$ lines contains one type of query described above.

Output

For each "MAX" query, output one line in the format of "ANSWER y", where $$$y$$$ the value you have calculated.

ExampleInput
5 6
MULTIPLY 3 5 2
MULTIPLY 2 5 3
MAX 1 5
MULTIPLY 1 4 2
MULTIPLY 2 5 5
MAX 3 5
Output
ANSWER 1
ANSWER 2
Note

If $$$m$$$ and $$$n$$$ are non-zero integers, or more generally, non-zero elements of an integral domain, it is said that $$$m$$$ divides $$$n$$$ if there exists an integer $$$k$$$, or an element $$$k$$$ of the integral domain, such that $$$m \times k=n$$$, and this is written as $$$m \mid n$$$.

加入题单

算法标签: