#include <bits/stdc++.h>


using namespace std;

//mt19937 rnd(time(0));
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define fr first
#define sc second
#define pb push_back
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define smin(x, y) x = min(x, y)
#define smax(x, y) x = max(x, y)
#define pii pair<int,int>
#define ld long double
#define int long long
#define pld pair<ld,ld>


const int N = 2e5 + 10;
const int inf = 1e18;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;


signed main() {
    ios;
    int n, m;
    cin >> n >> m;
    map<pair<int, int>, char> mp;
    int c1 = 0;
    int c2 = 0;
    while (m--) {
        string s;
        cin >> s;
        if (s == "+") {
            int v, u;
            string c;
            cin >> v >> u >> c;
            mp[{v, u}] = c[0];
            if (mp.count({u, v})) {
                if (mp[{u, v}] == c[0])++c2;
                else ++c1;
            }
        } else if (s == "-") {
            int v, u;
            cin >> v >> u;
            char q = mp[{v, u}];
            mp.erase({v, u});
            if (mp.count({u, v})) {
                if (mp[{u, v}] == q)c2--;
                else c1--;
            }
        } else {
            int k;
            cin >> k;
            if(k % 2 == 1){
                if(c1 || c2) cout << "YES\n";
                else cout << "NO\n";
            }else{
                if(c2)cout << "YES\n";
                else cout << "NO\n";
            }
        }
    }
}