#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <numeric>
#include <cassert>

#define endl '\n'
#define sp ' '

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn = 2e5+5;
set<pair<int,char>> adj[maxn];

int main(){
    
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
    int n,m;cin>>n>>m;
    set<pii> cift, samecift;
    for(int q=0;q<m;q++){
        char t;cin>>t;
        if(t == '+'){
            int u,v;char c;cin>>u>>v>>c;
            pair<int,char> p = {v,c};
            adj[u].emplace(v,c);
            auto it = adj[v].lower_bound({u,0});
            if(it != adj[v].end() && it->ff == u){
                int setu = min(u,v);
                int setv = max(u,v);
                cift.emplace(setu,setv);
                if(it->ss == c){
                    samecift.emplace(setu,setv);
                }
            }
        }
        else if(t == '-'){
            int u,v;cin>>u>>v;
            auto it = adj[u].lower_bound({v,0});
            assert(it != adj[u].end());
            adj[u].erase(it);
            int setu = min(u,v);
            int setv = max(u,v);
            auto it2 = cift.find({setu,setv});
            if(it2 != cift.end()){
                cift.erase(it2);
                it2 = samecift.find({setu,setv});
                if(it2 != samecift.end()){
                    samecift.erase(it2);
                }
            }
        }
        else{
            int k;cin>>k;
            if(k&1){
                if(cift.size()){
                    cout << "YES" << endl;
                }
                else
                    cout << "NO" << endl;
            }
            else{
                if(samecift.size()){
                    cout << "YES" << endl;
                }
                else{
                    cout << "NO" << endl;
                }
            }       
        }
    }
    
}











