#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD=998244353;

ll n,m,k,cnt1=0,cnt2=0;
map<pair<ll,ll>,ll> mmm;
pair<ll,ll> p;
pair<ll,ll> q;

ll fpow(ll Zenzenzense,ll Sparkle)
{
    ll Dream_Lantern=1;
    while(Sparkle>1)
    {
        if(Sparkle%2)
        {
            Dream_Lantern*=Zenzenzense;
        }
        Zenzenzense*=Zenzenzense;
        Sparkle/=2;
    }
    return Zenzenzense*Dream_Lantern;
}

ll fpow_MOD(ll Zenzenzense,ll Sparkle,ll Nandemonaiya)
{
    ll Dream_Lantern=1;
    while(Sparkle>1)
    {
        if(Sparkle%2)
        {
            Dream_Lantern*=Zenzenzense;
            Dream_Lantern%=Nandemonaiya;
        }
        Zenzenzense*=Zenzenzense;
        Zenzenzense%=Nandemonaiya;
        Sparkle/=2;
    }
    return (Zenzenzense*Dream_Lantern)%Nandemonaiya;
}

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

    cin>>n>>m;
    while(m--)
    {
        char c;
        cin>>c;
        if(c=='+')
        {
            ll u,v;
            char cc;
            cin>>u>>v>>cc;
            p.first=u;
            p.second=v;
            q.first=v;
            q.second=u;
            mmm[p]=cc;
            if(mmm[q])
            {
                cnt1++;
                if(mmm[p]==mmm[q])
                {
                    cnt2++;
                }
            }
        }
        else if(c=='-')
        {
            ll u,v;
            cin>>u>>v;
            p.first=u;
            p.second=v;
            q.first=v;
            q.second=u;
            if(mmm[q])
            {
                cnt1--;
                if(mmm[p]==mmm[q])
                {
                    cnt2--;
                }
            }
            mmm[p]=0;
        }
        else
        {
            cin>>k;
            if(k%2)
            {
                if(cnt1)
                {
                    cout<<"YES\n";
                }
                else
                {
                    cout<<"NO\n";
                }
            }
            else
            {
                if(cnt2)
                {
                    cout<<"YES\n";
                }
                else
                {
                    cout<<"NO\n";
                }
            }
        }
    }
}
