#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define uni(x) x.resize(unique(x.begin(), x.end()) - x.begin())
#define ms(x, n) memset(x, n, sizeof(x))
#define mc(a, b) memcpy(a, b, sizeof(b))
#define tomax(a, b) a = max(a, b)
#define tomin(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0;
const ll linf = 0x3f3f3f3f3f3f3f3fll;
const ll lninf = 0xc0c0c0c0c0c0c0c0ll;

map<pair<int, int>, char> f;

int main() {
	ios::sync_with_stdio(false);
	int m, n;
	int odd = 0, even = 0;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		char c;
		cin >> c;
		if (c == '+') {
			int u, v;
			char x;
			cin >> u >> v >> x;
			f[{u, v}] = x;
			if (f.find({v, u}) != f.end()) {
				odd++;
				if (f[{u, v}] == f[{v, u}]) even++;
			}
		}
		else if (c == '-') {
			int u, v;
			cin >> u >> v;
			if (f.find({v, u}) != f.end()) {
				odd--;
				if (f[{u, v}] == f[{v, u}]) even--;
			}
			f.erase({u, v});
		}
		else {
			int k;
			cin >> k;
			if (k % 2) cout << (odd ? "YES" : "NO") << endl;
			else cout << (even ? "YES" : "NO") << endl;
		}
	}
	return 0;
}
