#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;

int main(){
	map<PII, char> mp;
	map<PII, bool> pm;
	int cnt = 0; //count shuang xiang bians with the same char
	int cc = 0; //count the number of shuang xiang bian
	int n, m;
	cin >> n >> m;
	while(m --){
		char op;
		cin >> op;
		if (op == '+'){
			int x, y; char c;
			cin >> x >> y >> c;
			mp[make_pair(x, y)] = c;
			pm[make_pair(x, y)] = true;
			if (pm[make_pair(y, x)]){
				cc ++;
				if (mp[make_pair(y, x)] == c) cnt ++;
			}
		}
		if (op == '-'){
			int x, y;
			cin >> x >> y;
			if (pm[make_pair(y, x)]){
				cc --;
				if (mp[make_pair(y, x)] == mp[make_pair(x, y)]) cnt --;
			}
			pm[make_pair(x, y)] = false;
		}
		if (op == '?'){
			int k;
			cin >> k;
			if (k & 1){
				if (cc > 0){
					cout << "YES" << endl;
				}
				else cout << "NO" << endl;
			}
			else{
				if (cnt > 0) cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}
}
