Little E's Magic Puzzles
题号:NC244914
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Little E is a senior magic enthusiast. Recently, he has harvested a batch of magic puzzles. After arranging these puzzles in a row, he found that these puzzles can be operated in 3 ways:

1. You can select any two separate puzzles to connect them together.

2. You can select an interval of any size to connect all the puzzles in the interval.

3. Query any two puzzles.

Puzzles are numbered from 1 to n. When Little E operates in 3, he wants to know whether the two specified puzzles are connected. Please tell him.

输入描述:

In the first line, enter two positive integers n,m(), representing n pieces of puzzle, and perform m operations.

Next, m lines, each with three positive integers t, a, b . When t is taken as 1, it represents operation 1, connecting the puzzles numbered a and b. When t is taken as 2, it represents operation 2, connecting all puzzles within the range of . When t takes 3, query a and b to determine whether the two pieces of puzzle are connected together.

输出描述:

For each query, if the two puzzle pieces are connected, output "YES"; otherwise, ouput    "NO"
示例1

输入

复制
5 10
3 2 3
3 5 3
2 2 4
3 5 1
3 2 4
3 5 5
2 3 3
2 3 4
3 4 4
3 2 4

输出

复制
NO
NO
NO
YES
YES
YES
YES