#include<bits/stdc++.h>
#define xx first
#define yy second
using namespace std;
typedef pair<int, int>pi;
map<pi, int>mp;
int main()
{
    int n, q, c1= 0, c2= 0;
    scanf("%d %d", &n, &q);

    while(q--)
    {
        int u, v, k;
        char s1[2], s2[2];
        scanf("%s", s1);

        if(s1[0]=='+')
        {
            scanf("%d %d %s", &u, &v, s2);
            mp[{u, v}]= s2[0];
            if(mp.find({v, u})!=mp.end())
            {
                c1++;
                if(mp[{v, u}]==mp[{u, v}])c2++;
            }
        }
        else if(s1[0]=='-')
        {
            scanf("%d %d", &u, &v);
            if(mp.find({v, u})!=mp.end())
            {
                c1--;
                if(mp[{v, u}]==mp[{u, v}])c2--;
            }
            mp.erase({u, v});
        }
        else
        {
            scanf("%d", &k);
            if(k&1)
            {
                if(c1)puts("YES");
                else puts("NO");
            }
            else
            {
                if(c2)puts("YES");
                else puts("NO");
            }
        }
    }

    return 0;
}
