#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, q, f[N], nxt[N];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
void write(int x) {
  if (x < 0) {
    x = -x, putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
void writeln(int x) { write(x), puts(""); }
void writesp(int x) { write(x), putchar(' '); }
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void merge(int x, int y) {
  int tx = find(x), ty = find(y);
  if (tx != ty) f[tx] = ty;
}
signed main() {
  n = read(), q = read();
  for (int i = 1; i <= n; i++) f[i] = i, nxt[i] = i + 1;
  while (q--) {
    int opt = read(), x = read(), y = read();
    if (opt == 1) {
      merge(x, y);
    }
    if (opt == 2) {
      for (int i = x + 1, t; i <= y; i = t) {
        merge(i - 1, i);
        t = nxt[i];
        nxt[i] = nxt[y];
      }
    }
    if (opt == 3) {
      int tx = find(x), ty = find(y);
      if (tx != ty)
        puts("NO");
      else
        puts("YES");
    }
  }
  return 0;
}
