#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int n, cnt1, cnt2, m;
char s[10];
map<long long, char> M;
long long exc(int u, int v){
	return (long long)u * (n + 1) + v;
}
int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i){
		int u, v;
		cin >> s + 1;
		if(s[1] == '+'){
			cin >> u >> v;
			cin >> s + 1;
			M[exc(u, v)] = s[1];
			if(M[exc(v, u)]){
				if(s[1] == M[exc(v, u)])
					cnt1++;
				cnt2++;
			}
		}
		else if(s[1] == '-'){
			cin >> u >> v;
			if(M[exc(v, u)] == M[exc(u, v)]) cnt1--;
			if(M[exc(v, u)]) cnt2--;
			M[exc(u, v)] = 0;
		}
		else{
			int k;
			cin >> k;
			if(k & 1){
				if(cnt2) cout << "YES" << endl;
				else cout << "NO" << endl;
			} 
			else{
				if(cnt1) cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}
	return 0;
}