#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int mxN = 1e6 + 5;

int n, m;

int main() {
	ios :: sync_with_stdio(false), cin.tie(nullptr);
	cin >> n >> m;
	int cnt = 0;
	int odd = 0, even = 0;
	map <pair <int, int>, char> mp;
	for (int i = 1; i <= m; ++i) {
		char t;
		cin >> t;
		if (t == '+') {
			int u, v;
			char c;
			cin >> u >> v >> c;
			mp[{u, v}] = c;
			if (mp[{v, u}] != 0)
				++odd;
			if (mp[{v, u}] == mp[{u, v}])
				++even;
		}
		else if (t == '-') {
			int u, v;
			cin >> u >> v;
			if (mp[{u, v}] == mp[{v, u}])
				--even;
			if (mp[{v, u}] != 0)
				--odd;
			mp[{u, v}] = 0;
		}
		else if (t == '?') {
			int k;
			cin >> k;
			if (k & 1) 
				cout << (odd ? "YES" : "NO") << '\n';
			else
				cout << (even ? "YES" : "NO") << '\n'; 
		}
	}
	return 0;
}