#include <bits/stdc++.h>

using namespace std;
int n, m;
map<pair<int, int>, char> mp;

int main() {
    scanf("%d%d", &n, &m);
    mp.clear();
    int same = 0, two = 0;
    while (m--) {
        char s[10], C[10], op, c;
        int u, v;
        scanf("%s", s);
        op = s[0];
        if (op == '+') {
            scanf("%d%d%s", &u, &v, C);
            c = C[0], mp[{u, v}] = c;
            if (mp.count({v, u})) {
                ++two;
                if (mp[{v, u}] == c)++same;
            }
        } else if (op == '-') {
            scanf("%d%d", &u, &v);
            if (mp.count({v, u})) {
                --two;
                if (mp[{u, v}] == mp[{v, u}])--same;
            }
            mp.erase({u, v});
        } else {
            int k;
            scanf("%d", &k);
            puts((same || ((k & 1) && (two))) ? "YES" : "NO");
        }
    }
}
