joingraf

Time limit: 0.5s Memory limit: 64MB Input: Output:

Traian recently celebrated his birthday and received a graph with NN nodes as a gift. Initially, each node was in its own connected component. But then, Traian's dog came and asked him QQ questions of the following type:

  • 1 x y1 \ x \ y: Add edges to your graph as (x,x+1),(x+1,x+2),...,(y1,y)(x, x + 1), (x + 1, x + 2), ..., (y - 1, y)
  • 2 x y2 \ x \ y: Tell if nodes xx and yy are in the same connected component.

Task

Answer Traian's dog's questions.

Input data

The first line of the input contains NN and QQ, representing the number of nodes in the graph and the number of questions, respectively. The next QQ lines contain three numbers ti,xi,yit_i, x_i, y_i, where tit_i represents the type of the question, and xix_i and yiy_i are two nodes in the graph.

Output data

For each question of type 22, output the answer on a new line. The answer can be either Yes or No, depending on the result.

Constraints and clarifications

  • 1N,Q1061 \leq N, Q \leq 10^6
  • If an edge has already been added in a question of type 11, Traian will not add it again.
  • For questions of type 22, it is not guaranteed that xyx \leq y.
# Score Constraints
1 10 N100,Q100N \leq 100, Q \leq 100
2 10 N1 000,Q100N \leq 1\ 000, Q \leq 100
3 10 N104,Q104N \leq 10^4, Q \leq 10^4
4 20 N105,Q105N \leq 10^5, Q \leq 10^5
5 50 No additional constraints

Example

stdin

7 6
1 4 7
2 5 3
1 3 6
1 6 7
2 7 1
2 3 4

stdout

No
No
Yes

Explanation

After the first question, the graph will look like this:

The answer to the second question is no, because nodes 33 and 55 are not in the same connected component.
After the third question, the graph will look like this:

After the fourth question, the graph will look like this:

The answer to the fifth question is no, because nodes 11 and 77 are not in the same connected component.
The answer to the sixth question is yes, because nodes 33 and 55 are in the same connected component.

Log in or sign up to be able to send submissions!