#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

void solve()
{
    int n, m;
    cin >> n >> m;

    set<pii> eds;
    set<pair<pii, int>> cols;
    int even = 0, odd = 0;
    map<pii, int> color;
    while (m--)
    {
        char c;
        cin >> c;
        if (c == '+')
        {
            int u, v;
            char foo;
            cin >> u >> v >> foo;
            int cc = foo - 'a';
            if (eds.count({v, u}))
            {
                even++;
            }
            if (cols.count({{v, u}, cc}))
            {
                odd++;
            }
            eds.insert({u, v});
            cols.insert({{u, v}, cc});
            color[{u, v}] = cc;
        }
        else if (c == '-')
        {
            int u, v;
            cin >> u >> v;
            if (eds.count({v, u}))
            {
                even--;
            }
            if (cols.count({{v, u}, color[{u, v}]}))
            {
                odd--;
            }
            eds.erase({u, v});
            cols.erase({{u, v}, color[{u, v}]});
        }
        else
        {
            int k;
            cin >> k;
            --k;
            if (k % 2)
                cout << (odd ? "YES" : "NO") << endl;
            else
                cout << (even ? "YES" : "NO") << endl;
        }
    }
}

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

    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }

    time_taken();
    return 0;
}