#include <bits/stdc++.h>
using namespace std;
const long long maxN = 2e5 + 7, N = 13, MOD = 1e6 + 3, Mod = 1e9 + 7,
                INF = 1e14 + 7;
long long n, h[maxN], x, y, cur, help, badi[maxN], par[maxN], q, id;
int find_par(int x) {
  if (par[x] == x) return x;
  par[x] = find_par(par[x]);
  return par[x];
}
void merge(int x, int y) {
  int hx = find_par(x), hy = find_par(y);
  if (hx != hy) {
    if (h[hx] > h[hy]) swap(hx, hy);
    par[hx] = hy;
    if (h[hx] == h[hy]) h[hy]++;
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> q;
  for (int i = 1; i <= n; i++) par[i] = i, badi[i] = i + 1;
  for (int i = 1; i <= q; i++) {
    cin >> id >> x >> y;
    if (id == 1) merge(x, y);
    if (id == 2) {
      cur = x;
      while (cur < y) {
        merge(cur, y);
        help = cur;
        cur = badi[cur];
        badi[help] = badi[y];
      }
    }
    if (id == 3) {
      if (find_par(x) == find_par(y))
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
  return 0;
}
