#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 200005;
int idx[MAX];
int sze[MAX];
int nxt[MAX];
int root(int x) {
  while (x != idx[x]) {
    idx[x] = idx[idx[x]];
    x = idx[x];
  }
  return x;
}
bool conn(int p, int q) { return root(p) == root(q); }
void join(int p, int q) {
  int i = root(p);
  int j = root(q);
  if (sze[i] < sze[j]) {
    idx[i] = j;
    sze[j] += sze[i];
  } else {
    idx[j] = i;
    sze[i] += sze[j];
  }
}
void join2(int p, int q) {
  int curr = p + 1;
  while (curr <= q) {
    join(curr, curr - 1);
    int n = nxt[curr];
    nxt[curr] = max(nxt[curr], q);
    curr = max(n, curr + 1);
  }
}
int main() {
  for (int i = 0; i < MAX; i++) {
    idx[i] = i;
    sze[i] = 1;
    nxt[i] = i + 1;
  }
  int a, b;
  scanf("%d %d", &a, &b);
  for (int i = 0; i < b; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    if (x == 3) {
      cout << (conn(y, z) ? "YES" : "NO") << endl;
    } else if (x == 1) {
      if (conn(y, z)) {
        continue;
      }
      join(y, z);
    } else {
      join2(y, z);
    }
  }
}
