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

int n, m, a1, a2, k, v, u;
char c, t;
map <pair<int, int>, char> mp;

int main() {
    cin >> n >> m;
    while (m--) {
        cin >> t;
        if (t == '+') {
            cin >> v >> u >> c;
            mp[{v, u}] = c;
            if (mp.count({u, v})) {
                if (mp[{u, v}] == c)
                    a1++;
                else
                    a2++;
            }
        }
        else if (t == '-') {
            cin >> v >> u;
            c = mp[{v, u}];
            mp.erase({v, u});
            if (mp.count({u, v})) {
                if (mp[{u, v}] == c)
                    a1--;
                else
                    a2--;
            }
        }
        else {
            cin >> k;
            if (a1) {
                cout << "YES\n";
            }
            else {
                if (a2 && k % 2 == 1)
                    cout << "YES\n";
                else
                    cout << "NO\n";
            }
        }
    }
    return 0;
}

