#include <bits/stdc++.h>
#define int long long

using namespace std;

int n, m;
int countEqual = 0, countDouble = 0;
map<pair<int, int>, char> e;

int32_t main() {
    cin >> n >> m;
    for (int z = 0; z < m; ++z) {
        char c; cin >> c;
        if (c == '+') {
            int u, v; char l; cin >> u >> v >> l; u--; v--;
            if (e.count({v, u})) {
                countDouble++;
                if (e[{v, u}] == l) countEqual++;
            }
            e[{u, v}] = l;
        } else if (c == '-') {
            int u, v; cin >> u >> v; u--; v--;
            if (e.count({v, u})) {
                countDouble--;
                if (e[{v, u}] == e[{u, v}]) countEqual--;
            }
            e.erase({u, v});
        } else { // ?
            int k; cin >> k;
            if (k % 2 == 0) {
                if (countEqual) cout << "YES\n";
                else cout << "NO\n";
            } else {
                if (countDouble) cout << "YES\n";
                else cout << "NO\n";
            }
        }
    }
}
