← Home
write a go solution for Description:
You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty.

You should process m queries with it. Each query is one of three types:

- "+ u v c" — add arc from u to v with label c. It's guaranteed that there is no arc (u,v) in the graph at this moment;
- "- u v" — erase arc from u to v. It's guaranteed that the graph contains arc (u,v) at this moment;
- "? k" — find the sequence of k vertices v_1,v_2,...,v_k such that there exist both routes v_1tov_2to...tov_k and v_ktov_k-1to...tov_1 and if you write down characters along both routes you'll get the same string. You can visit the same vertices any number of times.

Input Format:
The first line contains two integers n and m (2<=n<=2*10^5; 1<=m<=2*10^5) — the number of vertices in the graph and the number of queries.

The next m lines contain queries — one per line. Each query is one of three types:

- "+ u v c" (1<=u,v<=n; uneqv; c is a lowercase Latin letter);
- "- u v" (1<=u,v<=n; uneqv);
- "? k" (2<=k<=10^5).

It's guaranteed that you don't add multiple edges and erase only existing edges. Also, there is at least one query of the third type.

Output Format:
For each query of the third type, print YES if there exist the sequence v_1,v_2,...,v_k described above, or NO otherwise.

Note:
In the first query of the third type k=3, we can, for example, choose a sequence [1,2,3], since 1xarrowa2xarrowb3 and 3xarrowa2xarrowb1.

In the second query of the third type k=2, and we can't find sequence p_1,p_2 such that arcs (p_1,p_2) and (p_2,p_1) have the same characters.

In the third query of the third type, we can, for example, choose a sequence [1,2,3,2,1], where 1xarrowa2xarrowb3xarrowd2xarrowc1.. Output only the code with no comments, explanation, or additional text.