#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
const ll mod=1000000007;
const char nl='\n';

void solve(){
    ll i,j,k,l,n,r,m,u,v,x,y;
	cin>>n>>m;
	vector< map<ll,char> > single(n+1), dsame(n+1),ddiff(n+1);
	char ch,dh;
	int same=0,diff=0;
	while(m--){
		cin>>ch;
		if(ch=='+'){
			cin>>u>>v>>ch;
			if(single[v].count(u)){
				dh=single[v][u];
				single[v].erase(u);
				if(ch==dh) dsame[u][v]=dsame[v][u]=ch, same++;
				else ddiff[u][v]=ch, ddiff[v][u]=dh, diff++;
			}
			else single[u][v]=ch;
		}
		else if(ch=='-'){
			cin>>u>>v;
			if(single[u].count(v)) single[u].erase(v);
			else if(dsame[u].count(v)){
				ch=dsame[v][u];
				dsame[u].erase(v);
				dsame[v].erase(u);
				single[v][u]=ch;
				same--;
			}
			else{
				ch=ddiff[v][u];
				ddiff[u].erase(v);
				ddiff[v].erase(u);
				single[v][u]=ch;
				diff--;
			}
		}
		else{
			cin>>k;
			if(same>0) cout<<"YES"<<nl;
			else if(k%2 and diff>0) cout<<"YES"<<nl;
			else cout<<"NO"<<nl;
		}
	}
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t = 1,i=1;
    // cin >> t;
    while (t--)
    {
        // cout<<"Case #"<< i++ <<": ";
        solve();
    }
    return 0;
}