#include <stdio.h>
#include <memory.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
const int N = 200005;

map<int, int> my[N];
map<int, int>::iterator it;

void slove() {
    int i = 0, n = 0, m = 0, x1 = 0, x2 = 0, one = 0, sp_one = 0, k = 0, u = 0, v = 0, now = 0;
    char str[256] = { 0 };
    scanf("%d%d", &n, &m);
    while (m --) {
        scanf("%s", str);
        if (str[0] == '+') {
            scanf("%d%d%s", &u, &v, str);
            x1 = my[u][v] = str[0] - 'a' + 1;
            it = my[v].find(u);
            
            if (it != my[v].end()) {
                one ++;
                x2 = it->second;
                if (x2 == x1) {
                    sp_one ++;
                }
            }
                
        }
        else if (str[0] == '-') {
            scanf("%d%d", &u, &v);
            x1 = my[u][v];
            my[u].erase(v);
            it = my[v].find(u);
            if (it != my[v].end()) {
                one --;
                x2 = it->second;
                if (x1 == x2) {
                    sp_one --;
                }
                
            }
                    
        }
        else {
            scanf("%d", &k);
            if (one == 0) {
                printf("NO\n");
            }
            else if (sp_one) {
                printf("YES\n");
            }
            else if (k % 2 == 1) {
                printf("YES\n");
            }
            else {
                printf("NO\n");
            }
        }
    }
    
}

int main() {
    int o = 1;
    //scanf("%d", &o);
    while (o --) {
        slove();
        //fflush(stdout);
    }
    return 0;
}
