#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie();
    cout.tie();

    int n,m;
    cin>>n>>m;
    vector < set <int> > g(n);
    map < pair <int,int> ,char> M;
    int A=0,B=0;
    while(m--){
        char t;
        cin>>t;
        if(t=='+'){
            int a,b;
            char c;
            cin>>a>>b>>c;
            a--,b--;
            if(g[b].find(a)!=g[b].end()){
                if(M[{b,a}]==c)
                    A++;
                else
                    B++;
            }
            g[a].insert(b);
            M[{a,b}]=c;
        }
        else if(t=='-'){
            int a,b;
            cin>>a>>b;
            a--,b--;
            char c=M[{a,b}];
            if(g[b].find(a)!=g[b].end()){
                if(M[{b,a}]==c)
                    A--;
                else
                    B--;
            }
            g[a].erase(g[a].find(b));
        }
        else{
            int k;
            cin>>k;
            if(A || (B && k%2))
                cout<<"YES"<<'\n';
            else
                cout<<"NO"<<'\n';
        }
    }

    return 0;
}
