#include <bits/stdc++.h>

using namespace std;

int n, m;

map< pair<int,int>, char > mp1;

set< pair<int,int> > diff;
set< pair<int,int> > equl;

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    cin >> n >> m;

    for ( int i=0; i<m; i++ )
    {
        char t;
        cin >> t;

        if ( t == '+' )
        {
            int u, v;
            char c;
            cin >> u >> v >> c;

            mp1[make_pair(u,v)] = c;

            map<pair<int,int>, char> :: iterator  it;
            it = mp1.find( make_pair( v, u ) );

            if ( it != mp1.end() )
            {
                if ( u > v )
                    swap( u, v );

                if ( it->second == c )
                    equl.insert( make_pair(u, v) );

                else
                    diff.insert( make_pair(u, v) );
            }

        } else if ( t == '-' )
        {
            int u, v;
            cin >> u >> v;

            map< pair<int,int>, char> :: iterator it1, it2;

            it1 = mp1.find( make_pair(u, v) );
            it2 = mp1.find( make_pair(v, u) );

            if ( it2 != mp1.end() )
            {
                if ( u > v )
                    swap( u, v );

                if ( it1->second == it2->second )
                    equl.erase( make_pair(u, v) );

                else
                    diff.erase( make_pair(u, v) );
            }

            mp1.erase(it1);

        } else
        {
            int k;
            cin >> k;

            if ( k & 1 )
            {
                if ( diff.size() > 0 || equl.size() > 0 )
                    cout << "YES\n";

                else
                    cout << "NO\n";

            } else
            {
                if ( equl.size() > 0 )
                    cout << "YES\n";

                else
                    cout << "NO\n";

            }

        }
    }

    return 0;
}
