#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int pa1[maxn], pa2[maxn];
int findpa(int *&pa, int x) {
  return x == pa[x] ? x : pa[x] = findpa(pa, pa[x]);
}
void Union(int *&pa, int x, int y) {
  x = findpa(pa, x);
  y = findpa(pa, y);
  pa[x] = y;
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 1; i <= N + 1; i++) pa1[i] = i, pa2[i] = i;
  int *p1 = pa1, *p2 = pa2;
  while (M--) {
    int opt, l, r;
    scanf("%d%d%d", &opt, &l, &r);
    if (opt == 1) Union(p1, l, r);
    if (opt == 2) {
      for (int i = l; i <= r; i++) {
        i = findpa(p2, i);
        if (i > r) break;
        if (i != r) pa2[i] = i + 1;
        Union(p1, i, r);
      }
    };
    if (opt == 3) {
      if (findpa(p1, l) == findpa(p1, r))
        puts("YES");
      else
        puts("NO");
    }
  }
  return 0;
}
