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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, k, a, b, cnt1 = 0, cnt2 = 0;
    cin >> n >> m;
    char c1, c2, c3;

    map<pair<int, int>, char> mp1, mp2;

    for (int i = 0; i < m; i++) {
        cin >> c1;
        if (c1 == '+') {
            cin >> a >> b >> c2;
            if (a < b) {
                mp1[{a, b}] = c2;
                if (mp2.count({b, a}) == 0) continue;
                if (mp2[{b, a}] < 'a' || mp2[{b, a}] > 'z') continue;
                cnt1++;
                if (mp1[{a, b}] == mp2[{b, a}]) cnt2++;
            }
            else {
                mp2[{a, b}] = c2;
                if (mp1.count({b, a}) == 0) continue;
                if (mp1[{b, a}] < 'a' || mp1[{b, a}] > 'z') continue;
                cnt1++;
                if (mp2[{a, b}] == mp1[{b, a}]) cnt2++;
            }
        }
        else if (c1 == '-') {
            cin >> a >> b;
            if (a < b) {
                c3 = mp1[{a, b}];
                mp1[{a, b}] = '-';
                if (mp2.count({b, a}) == 0) continue;
                if (mp2[{b, a}] < 'a' || mp2[{b, a}] > 'z') continue;
                cnt1--;
                if (c3 == mp2[{b, a}]) cnt2--;
            }
            else {
                c3 = mp2[{a, b}];
                mp2[{a, b}] = '-';
                if (mp1.count({b, a}) == 0) continue;
                if (mp1[{b, a}] < 'a' || mp1[{b, a}] > 'z') continue;
                cnt1--;
                if (c3 == mp1[{b, a}]) cnt2--;
            }
        }
        else {
            cin >> k;
            if (k % 2) {
                if (cnt1) cout << "YES\n";
                else cout << "NO\n";
            }
            else {
                if (cnt2) cout << "YES\n";
                else cout << "NO\n";
            }
        }


    }
}
