PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#DSU0000096. Tái cơ cấu công ty (Restructuring Company)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tái cơ cấu công ty (Restructuring Company)

Restructuring Company

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A company has nn employees numbered 11 through nn. Initially every employee is in a separate department. Process qq operations in order: 1 x y merges the departments containing employees xx and yy; 2 x y merges all departments containing employees with indices in [x,y][x,y] (where x≤yx\le y); 3 x y asks whether employees xx and yy belong to the same department. Merging departments never changes employee indices.

Input

The first line contains n,qn,q. Each following line contains three integers t,x,yt,x,y.

Output

For each query of type 3, print YES if the employees share a department, otherwise print NO.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30, 1≤q≤401\le q\le 40, 1≤x,y≤n1\le x,y\le n, t∈{1,2,3}t\in\{1,2,3\}; for t=2t=2, x≤yx\le y.
  • Subtask 2 (30 points): 1≤n≤2501\le n\le 250, 1≤q≤2501\le q\le 250, 1≤x,y≤n1\le x,y\le n, t∈{1,2,3}t\in\{1,2,3\}; for t=2t=2, x≤yx\le y.
  • Subtask 3 (50 points): 1≤n≤2⋅1051\le n\le 2\cdot10^5, 1≤q≤5⋅1051\le q\le 5\cdot10^5, 1≤x,y≤n1\le x,y\le n, t∈{1,2,3}t\in\{1,2,3\}; for t=2t=2, x≤yx\le y.

Examples

Input

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

Output

NO
YES
YES

Explanation

Employees 22 and 55 initially belong to different departments. After merging, they share one; the interval merge connects employee 77 to that group.