#include <bits/stdc++.h>
using namespace std;
int n, q, fa[250000], order, x, y, park[250000];
int fond(int x) { return x == fa[x] ? x : fa[x] = fond(fa[x]); }
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    park[i] = i + 1;
  }
  while (q--) {
    scanf("%d%d%d", &order, &x, &y);
    if (order == 3) {
      if (fond(x) != fond(y))
        printf("NO\n");
      else
        printf("YES\n");
    } else if (order == 2) {
      for (int i = x + 1; i <= y;) {
        fa[fond(i)] = fond(i - 1);
        int temp = park[i];
        park[i] = y + 1;
        i = temp;
      }
    } else if (order == 1)
      fa[fond(x)] = fond(y);
  }
  return 0;
}
