// chrono::system_clock::now().time_since_epoch().count()
#include <bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = (int)2e5 + 5;

set<pair<int, char>> adj[MAXN];
int n, q;

void solve() {
    cin >> n >> q;
    set<pii> nice1, nice2;
    
    rep (i, 0, q) {
        char tp;
        cin >> tp;
        
        if (tp == '+') {
            int u, v;
            char c;
            cin >> u >> v >> c;
            adj[u].insert(mp(v, c));
            auto it = adj[v].lower_bound(mp(u, 'a'));
            
            if (it != adj[v].end() && it -> fi == u) {
                if (it -> se == c) {
                    nice1.insert(mp(min(u, v), max(u, v)));
                }
                else {
                    nice2.insert(mp(min(u, v), max(u, v)));
                }
            }
        }
        else if (tp == '-') {
            int u, v;
            cin >> u >> v;
            nice1.erase(mp(min(u, v), max(u, v)));
            nice2.erase(mp(min(u, v), max(u, v)));
            adj[u].erase(adj[u].lower_bound(mp(v, 'a')));
        }
        else {
            int k;
            cin >> k;
            
            if (!nice1.empty()) {
                cout << "YES" << '\n';
            }
            else if (!nice2.empty() && k % 2 == 1) {
                cout << "YES" << '\n';
            }
            else {
                cout << "NO" << '\n';
            }
        }
    }
}

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

    int tt = 1;
    
    while (tt--) {
        solve();
    }

    return 0;
}
