#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;

unordered_map<int, char> mp[MAXN];


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

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;

    int tk = 0, cf = 0;
 
    for(int i = 0; i < m; i++){
        char c;
        cin>>c;
        
        if(c == '+'){
            int a, b;
            char ch;
            cin>>a>>b>>ch;
            mp[a][b] = ch;
            auto u = mp[b].find(a);
            if(u != mp[b].end()){
                if((*u).ss == ch){
                    cf++;
                }else{
                    tk++;
                }
            }
        }else if(c == '-'){
            int a, b;
            char ch;
            cin>>a>>b;
            ch = mp[a][b];
            mp[a].erase(b);

            auto u = mp[b].find(a);
            if(u != mp[b].end()){
                if((*u).ss == ch){
                    cf--;
                }else{
                    tk--;
                }
            }
        }else {
            int k;
            cin>>k;
            if(k % 2 == 1){
                cout<< ((cf || tk) ? "YES" : "NO")<<endl;
            }else{
                cout<<(cf ? "YES" : "NO")<<endl;
            }
        }
    }

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}