#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>

using namespace std;

int N, M;
int nod1[400002], nod2[400002];
long long val[400002];

long long AIB[100002];
void update(int x, long long val)
{
	for (; x <= N; x += x & -x)
		AIB[x] ^= val;
}
long long query(int x)
{
	long long sum = 0;
	for (; x >= 1; x -= x & -x)
		sum ^= AIB[x];
	return sum;
}

int main()
{
	cin >> N >> M;
	
	srand(time(0));
	for (int i = 1, type; i <= M; ++i)
	{
		cin >> type;
		if (type == 1)
		{
			val[++val[0]] = 1LL * rand() * rand() * rand() * rand();
			
			cin >> nod1[val[0]] >> nod2[val[0]];
			
			update(nod1[val[0]], val[val[0]]);
			update(nod2[val[0]], val[val[0]]);
		}
		else if (type == 2)
		{
			int tnow;
			cin >> tnow;
			
			update(nod1[val[0]], val[tnow]);
			update(nod2[val[0]], val[tnow]);
		}
		else
		{
			int i1, i2;
			cin >> i1 >> i2;
			
			long long res = query(max(i1, i2)) ^ query(min(i1, i2) -1 );
			if (res == 0) cout << "YES\n";
			else          cout << "NO\n";
		}
	}
}