#include <bits/stdc++.h>
using namespace std;
long long n, q, opt, x, y;
long long nxt[200005], fa[200005];
inline long long find(long long x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}
inline void merge(long long x, long long y) {
  long long kx = find(x), ky = find(y);
  if (kx != ky) fa[ky] = kx;
}
inline long long read() {
  long long f = 1, s = 0;
  char ch = getchar();
  while (!isdigit(ch)) (ch == '-') && (f = -1), ch = getchar();
  while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return f * s;
}
inline void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  n = read(), q = read();
  for (register long long i = 1; i <= n; ++i) fa[i] = i, nxt[i] = i + 1;
  for (register long long i = 1; i <= q; ++i) {
    opt = read(), x = read(), y = read();
    switch (opt) {
      case 1:
        merge(x, y);
        break;
      case 2: {
        for (register long long i = x + 1; i <= y;)
          merge(i - 1, i), x = nxt[i], nxt[i] = nxt[y], i = x;
        break;
      }
      case 3:
        printf(find(x) == find(y) ? "YES\n" : "NO\n");
        break;
    }
  }
  return 0;
}
