In Croatia there are $n$ radio stations. Each station has a concession on one of $n$ frequencies denoted by positive integers from 1 to $n$. The frequencies were not chosen ideally so sometimes noise appears when multiple stations are broadcasting at the same time. To be more precise, if two radio stations, with frequencies $a$ and $b$ respectively, are broadcasting at the same time, noise will appear if $a$ and $b$ are not relatively prime. The listeners, of course, do not like the noise, so when they hear it they switch to another station. To solve this noise problem, the radio station owners are asking you to write a program which simulates the actions of the radio stations. Your program needs to support two types of queries:
- $S$ $x$: If not currently broadcasting, the station with frequency $x$ starts broadcasting, and if it is already broadcasting, it stops.
- $C$ $l$ $r$: Check if there exists a pair of broadcasting stations whose frequencies $a$ and $b$ are from the interval [l, r] and such that gcd(a, b)̸ = 1. If such a pair exists, print DA, otherwise print NE. Initially, no station is broadcasting.
Input
The first line contains positive integers $n$ and $q$ ($1 \le n \le 1,000,000$, $1 \le q \le 200,000$), the number of radio stations (and frequencies), and the number of queries, respectively. The $i$-th of the next $q$ lines contains a description of the $i$-th query. For queries of the first type it will hold that $1 \le x \le n$, and for queries of the second type it will hold that $1 \le l \le r \le n$.
Output
Print the answers to the queries of the second type in order, in separate lines.
Example 1
6 8 S 1 S 2 S 3 C 1 6 S 6 C 1 6 S 2 C 1 6
NE DA DA
Example 2
11 6 S 4 S 10 C 3 11 C 2 7 S 6 C 2 7
DA NE DA
Example 3
20 7 S 10 S 15 S 3 C 10 15 S 10 C 3 15 C 3 10
DA DA NE
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.