#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define int ll
#define all(c) begin(c),end(c)
using ll = long long;
const int MOD = 1e9+7, N = 2e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n, m;
   cin >> n >> m;
   map<array<int, 2>, int> cnt;
   set<array<int, 2>> always;
   multiset<int> val;
   while (m--) {
      char c;
      cin >> c;
      if (c == '+') {
         int u, v;
         char c;
         cin >> u >> v >> c;
         cnt[{u, v}] = c;
         if (cnt[{v, u}]) {
            if (cnt[{v, u}] == c) {
               always.insert({u, v});
               always.insert({v, u});
            }
            val.erase(val.find(1));
            val.insert(2);
         } else {
            val.insert(1);
         }
      } else if (c == '-') {
         int u, v;
         cin >> u >> v;
         if (cnt[{u, v}] and cnt[{v, u}]) {
            val.erase(val.find(2));
            val.insert(1);
            if (always.count({u, v})) {
               always.erase({u, v});
               always.erase({v, u});
            }
         } else {
            val.erase(val.find(1));
         }
         cnt[{u, v}] = 0;
      } else {
         int k;
         cin >> k;
         if (always.size()) {
            cout << "YES\n";
            continue;
         }
         if (val.find(2) == val.end()) {
            cout << "NO\n";
         } else if (k & 1) {
            cout << "YES\n";
         } else {
            cout << "NO\n";
         }
      }
   }
   return 0;
}