#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(v) v.begin(),v.end()
#define display(A) for(auto &x:A) cout << x<<" ";cout <<"\n";
#define read(A) for(auto &x:A) cin>>x;

ll mod = 998244353,n,m,q,k,flag;


void solve(){
	cin>>n>>q;
	map<pair<ll,ll>,char> mp;
	int isSame =0, isCompleted=0;
	while(q--){
		char x; cin>>x;
		ll a,b;
		if(x=='+'){
			cin>>a>>b;
			char c; cin>>c;
			mp[{a,b}]=c;
			if(mp.find({b,a})!=mp.end()){
				isCompleted++;
				if(mp[{b,a}]==mp[{a,b}]) isSame++;
			}
		}
		else if(x=='-'){
			cin>>a>>b;
			if(mp.find({b,a})!=mp.end()){
				isCompleted--;
				if(mp[{b,a}]==mp[{a,b}]) isSame--;
			}
			mp.erase({a,b});
		}
		else{
			cin>>k;
			if(k%2){
				if(isCompleted) cout <<"YES\n";
				else cout <<"NO\n";
			}
			else{
				if(isSame) cout <<"YES\n";
				else cout <<"NO\n";
			}
		}
	}
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	// int  t=1;cin>>t;while(t--) 
	solve();
	return 0;
}