P8123 [BalticOI 2021] Inside information (Day1)
Description
There are $N$ servers. The $i$-th server stores the $i$-th data block at the beginning. Now there are several types of operations:
- `S a b`: Server $a$ and server $b$ share data. That is, after the operation, both servers will contain the union of the data blocks originally held by these two servers, with duplicates removed (you can think of it as the union of data blocks).
- `Q a d`: Query whether server $a$ has data block $d$.
- `C a`: Query the number of servers that store data block $a$.
There are exactly $N-1$ `S` operations. If we treat each share as adding an edge, in the end these edges form a tree with the $N$ servers as nodes. In total, there are $K$ operations of type `Q` and `C`.
For each `Q` operation and `C` operation, output the corresponding result.
Input Format
The first line contains two integers $N, K$, representing the number of servers and the number of query operations.
The next $N+K-1$ lines each describe one operation.
Output Format
Output $K$ lines:
- For a `Q` operation, output `yes` or `no` to indicate whether it has data block $d$.
- For a `C` operation, output one integer representing the number of servers.
Explanation/Hint
#### Constraints
**This problem uses bundled testdata.**
- Subtask 1 (5 pts): $N \le 4000$.
- Subtask 2 (5 pts): Server $1$ shares data with servers $2, 3, \cdots, N$.
- Subtask 3 (10 pts): If $|A-B|=1$, then server $A$ shares data with server $B$.
- Subtask 4 (20 pts): If $A