#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

    int n, m;
    cin >> n >> m;

    int even = 0, odd = 0;
    map<pair<int, int>, char> mp;

    for(int i = 0; i < m; i++){
        char q;
        cin >> q;
        if(q == '+'){
            int u, v;
            char c;
            cin >> u >> v >> c;
            mp[{u,v}] = c;
            if(mp[{v, u}]){
                odd++;
                if(mp[{u, v}] == mp[{v, u}]) even++;
            }
        }
        else if(q == '-'){
            int u, v;
            cin >> u >> v;
            if(mp[{v, u}]){
                odd--;
                if(mp[{u, v}] == mp[{v, u}]) even--;
            }
            mp.erase(mp.find({u, v}));
        }
        else{
            int k;
            cin >> k;
            if(k % 2 && odd || k % 2 == 0 && even) cout << "YES\n";
            else cout << "NO\n";
        }
    }

    return 0;
}
