#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    void init(int n) {
        N = n;
        edges.clear();
        odds = 0;
        evens = 0;
    }

    void add(int u, int v, char ch) {
        auto e = (long long) u << 20 | v;
        auto re = (long long) v << 20 | u;
        auto it = edges.find(re);
        char ch0 = '?';
        if (it != edges.end()) {
            ch0 = it->second;
            ++evens;
        }
        if (ch0 == ch) {
            ++odds;
        }
        edges[e] = ch;
    }


    void remove(int u, int v) {
        auto e = (long long) u << 20 | v;
        auto re = (long long) v << 20 | u;
        auto ch = edges[e];
        edges.erase(e);
        auto it = edges.find(re);
        if (it == edges.end()) {
            return;
        }
        auto ch0 = it->second;
        if (ch0 == ch) {
            --odds;
        }
        --evens;
    }

    bool query(int K) {
        if (odds > 0) {
            return true;
        }
        if (K % 2 == 0) {
            return false;
        }
        assert(evens >= 0);
        return evens > 0;
    }



private:
    int N;
    map<long long, char> edges;
    long long odds;
    long long evens;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    Solution sol;

    int n;
    int m;
    cin >> n >> m;

    sol.init(n);

    for (int i = 0; i < m; ++i) {
        char op;
        cin >> op;
        if (op == '+') {
            int u, v;
            char ch;
            cin >> u >> v >> ch;
            --u, --v;
            sol.add(u, v, ch);
        } else if (op == '-') {
            int u, v;
            char ch;
            cin >> u >> v;
            --u, --v;
            sol.remove(u, v);
        } else {
            int k;
            cin >> k;
            if (sol.query(k)) {
                cout << "YES\n";
            } else {
                cout << "NO\n";
            }
        }
    }

    return 0;
}