Drawing and Erasing
Our friend Mickey Mouse has a forest consisting of N vertices. Mickey wants to perform the following three operations on these vertices:
1. **Draw an edge** between two vertices. 2. **Erase the last X drawn edges**. 3. **Check if a path exists** between two vertices.
Your task is to help Mickey quickly respond to the third operation.
Input
The first line contains N (1 ≤ N ≤ 10^5), representing the number of vertices. The second line contains Q (1 ≤ Q ≤ 10^5), which is the number of queries of the three types. During processing, maintain a variable p, initially set to 0. Each query of type 0 and 2 is given by a triplet of numbers 0 x_i y_i, which determines the vertex numbers between which you need to draw an edge or check for a path, calculated as follows:
- A_i = ((x_i + p + i) mod N) + 1 - B_i = ((y_i + 1 - p + i) mod N) + 1
(1 ≤ A_i, x_i, B_i, y_i ≤ N).
Queries of type 1 are given by a pair of numbers 1 x_i, where x_i is not greater than the number of edges drawn at that moment. After each query of type 2, update p with the result (YES = 1, NO = 0).
Output
For each query of type 2, output "YES" (without quotes) if there is a path between the two vertices, otherwise output "NO" (without quotes) if no path exists.