#include <bits/stdc++.h>
#define maxn 200010
using namespace std;

int n, m;
map<int, int> e[maxn];

int main()
{
	scanf("%d%d", &n, &m);
	int loop = 0, sloop = 0;
	while (m -- )
	{
		string op, c; int u, v, k;
		cin >> op;
		if (op[0] == '-')
		{
			cin >> u >> v;
			if (e[v].count(u)) loop -- ;
			if (e[v].count(u) && e[v][u] == e[u][v]) sloop -- ;
			e[u].erase(v);
		}
		else if (op[0] == '+')
		{
			cin >> u >> v >> c;
			e[u][v] = c[0] - 'A';
			if (e[v].count(u)) loop ++ ;
			if (e[v].count(u) && e[v][u] == c[0] - 'A') sloop ++ ;
		}
		else
		{
			cin >> k;
			if (!loop) { puts("NO"); continue; }
			if (k & 1) puts("YES");
			else
			{
				if (sloop) puts("YES");
				else puts("NO");
			}
		}
	}
}