#include <bits/stdc++.h>
using namespace std;
int n, m;
int par[200001], dp[200001], way[200001], k;
void mset() {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    dp[i] = 1;
  }
}
int fndset(int v) {
  if (v == par[v]) return v;
  return par[v] = fndset(par[v]);
}
void uset(int a, int b) {
  a = fndset(a);
  b = fndset(b);
  if (a != b) {
    if (dp[a] < dp[b]) swap(a, b);
    par[b] = a;
    dp[a] += dp[b];
  }
}
void unset(int a, int b) {
  for (int i = a + 1; i <= b; i++) {
    uset(i - 1, i);
    k = i;
    if (way[i]) {
      i = way[i];
    }
    way[k] = b;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  mset();
  int type, x, y;
  for (int i = 1; i <= m; i++) {
    cin >> type >> x >> y;
    if (type == 1) {
      uset(x, y);
      continue;
    }
    if (type == 2) {
      unset(x, y);
      continue;
    }
    if (fndset(x) != fndset(y)) {
      cout << "NO"
           << "\n";
      continue;
    }
    cout << "YES"
         << "\n";
  }
  return 0;
}
