#T13. 亲戚
亲戚
Description
If a family becomes too large, determining whether two individuals are relatives can indeed be quite challenging. Now, given a relationship graph of relatives, find the number of people in the family of any given individual.
Rule: If x and y are relatives, and y and z are relatives, then x and z are also relatives. If x and y are relatives, then all relatives of x are also relatives of y, and all relatives of y are also relatives of x.
Input Format
First line: Three integers n (n ≤ 100,000, m ≤ 200,000), representing the number of people and the number of pieces of information, respectively.
The following m lines: The information comes in two forms:
- M a b: Indicates that a and b are relatives.
- Q a: Requests the output of the number of people in the family to which a belongs.
Output Format
Output the number of people in the family to which a belongs.
5 10
M 3 2
Q 4
M 1 2
Q 4
M 3 2
Q 1
M 3 1
Q 5
M 4 2
Q 4
1
1
3
1
4