#include<bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2")
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
#define umap unordered_map
#define uset unordered_set
#define PI 3.14159265358979323846
#define E  2.71828182845904523536  
#define nl '\n'
#define LINF 1e18
#define INF (1 << 30)


int main(){
    FASTIO
    PRECISION
    int n;
    int q;
    cin >> n >> q;
    map<pi, char> m;
    set<pi> cyc;
    set<pi> syc;
    for(; q > 0; q--){
        char c;
        cin >> c;
        if(c == '+'){
            int a,b;
            cin >> a >> b >> c;
            pi p(a,b);
            m[p] = c;
            char d = m[pi(b,a)];
            if(d != 0){
                cyc.insert(pi(b,a));
                cyc.insert(p);
                if(c == d){
                    syc.insert(pi(b,a));
                    syc.insert(p);
                }
            }
        }else if(c == '-'){
            int a,b;
            cin >> a >> b;
            auto it = cyc.find(pi(a,b));
            if(it != cyc.end()){
                cyc.erase(it);
                it = cyc.find(pi(b,a));
                cyc.erase(it);
            }

            it = syc.find(pi(a,b));
            if(it != syc.end()){
                syc.erase(it);
                it = syc.find(pi(b,a));
                syc.erase(it);
            }
            m[pi(a,b)] = 0;
        }else{
            int k;
            cin >> k;
            if(k & 1){cout << (cyc.size() ? "YES\n" : "NO\n");}
            else{cout << (syc.size() ? "YES\n" : "NO\n");}
        }
    }

}