#include <bits/stdc++.h>
using namespace std;
int a[200010], ne[200010];
int n;
long long q;
int main() {
  int f(int i);
  cin >> n >> q;
  for (int i = 0; i <= n; i++) {
    a[i] = i;
    ne[i] = i + 1;
  }
  int m, x, y;
  while (q--) {
    scanf("%d%d%d", &m, &x, &y);
    switch (m) {
      case 1: {
        int x1 = f(x), y1 = f(y);
        if (x1 != y1) a[x1] = y1;
        break;
      }
      case 2: {
        int temp;
        for (int i = x + 1; i <= y; i = temp) {
          int x1 = f(i - 1), y1 = f(i);
          if (x1 != y1) a[x1] = y1;
          temp = ne[i];
          ne[i] = ne[y];
        }
        break;
      }
      case 3: {
        int x1 = f(x), y1 = f(y);
        if (x1 == y1)
          printf("YES\n");
        else
          printf("NO\n");
        break;
      }
    }
  }
  return 0;
}
int f(int i) {
  if (a[i] == i)
    return i;
  else
    return a[i] = f(a[i]);
}
