#include <bits/stdc++.h>
using namespace std;
int n, q, nt;
int fa[200011];
int f[200011];
int c, x, y, xx, yy;
int read() {
  int _ = 0, __ = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') __ = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    _ = _ * 10 + ch - '0';
    ch = getchar();
  }
  return _ * __;
}
int find(int a) {
  if (fa[a] == a) return a;
  return fa[a] = find(fa[a]);
}
int main() {
  n = read();
  q = read();
  for (int i = 1; i <= n; i++) fa[i] = i, f[i] = i + 1;
  for (int i = 1; i <= q; i++) {
    c = read();
    x = read();
    y = read();
    if (c == 1) {
      xx = find(x);
      yy = find(y);
      if (xx == yy) continue;
      fa[yy] = xx;
    } else if (c == 2) {
      for (int j = x + 1; j <= y; j = nt) {
        nt = f[j];
        xx = find(j - 1);
        yy = find(j);
        if (xx != yy) fa[yy] = xx;
        f[j] = f[y];
      }
    } else if (c == 3) {
      xx = find(x);
      yy = find(y);
      if (xx == yy) {
        printf("YES\n");
      } else
        printf("NO\n");
    }
  }
  return 0;
}
