#include <bits/stdc++.h>
using namespace std;
const int N = 200008;
int n, q;
int fa[N];
int back[N];
int find(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = find(fa[x]);
}
void merge(int x, int y) {
  int f1, f2;
  f1 = find(x);
  f2 = find(y);
  if (f1 == f2) return;
  fa[f1] = f2;
}
bool ask(int x, int y) {
  int f1, f2;
  f1 = find(x);
  f2 = find(y);
  if (f1 == f2) return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) fa[i] = i, back[i] = i + 1;
  for (int i = 1; i <= q; i++) {
    int opt, x, y;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) {
      merge(x, y);
    }
    if (opt == 2) {
      int to;
      for (int i = x + 1; i <= y; i = to) {
        merge(i - 1, i);
        to = back[i];
        back[i] = back[y];
      }
    }
    if (opt == 3) {
      if (ask(x, y))
        printf("YES\n");
      else
        printf("NO\n");
    }
  }
}
