#include<bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a) - 1; i>=(b);i--)
#define rep(i,n) FOR(i,0,n)
#define PB push_back
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FILL(a, value) memset(a, value, sizeof(a))
#define IOS ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0);
 
 
typedef  long long LL ;
typedef  vector<int > VI ;
typedef vector<LL > VL;
typedef pair<int,int > PII;
typedef pair<LL,LL> PLL;
 
const LL LINF = (LL)1e18 +47;
const int INF =  (int)1e9  +47  ;
const int MOD =(int)1e9 + 7 ;
const int modulo = 998244353;
const int nax =  1e6 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);



map<PII,char> mp ;
int main()
{
	
    //freopen("C:\\pocketcpp\\QuickStart\\test.txt","r",stdin);
    IOS;
    int n,m;
	cin >> n >> m;
	set<PII> s1;
	set<PII> s2; 
	rep(i,m)
	{
		char x;
		cin >> x;
		if(x =='+')
		{
			int a,b;
			cin >> a >> b ;
			--a,--b;
		    char c;
			cin >> c;
			mp[{a,b}] =c;
			if(mp.count({b,a}))
			{
				if(mp[{b,a}] !='!')
			{
				if(mp[{b,a}] == c)
				{
					s1.insert({a,b}); 
                    s1.insert({b,a});					
				}
				else 
				{
					s2.insert({a,b});
					s2.insert({b,a});
				}
		   }
			}
		}
		if(x =='-')
		{
			int a,b;
			cin >> a >> b;
			--a,--b;
			if(mp.count({a,b}) && mp.count({b,a}))
			{
				if(mp[{a,b}] !='!' && mp[{b,a}]!='!')
			{
				if(mp[{a,b}] == mp[{b,a}])
				{
					s1.erase({a,b});
					s1.erase({b,a});
				}
				else 
				{
				  s2.erase({b,a});
				  s2.erase({a,b});
				}
			}
			}
			mp[{a,b}] = '!'; 
		}
		if(x =='?')
		{
			int k;
			cin >> k ;
			if(k % 2 !=0)
			{
				if(!s1.empty() || !s2.empty())cout << "YES\n";
				else cout << "NO\n";
			}
			else 
			{
				if(!s1.empty())cout << "YES\n";
				else cout <<"NO\n"; 
			}
		}
	}
}
