#t529. 亲戚2

亲戚2

Relatives 2

Problem Background

Special for beginners, ^_^

Problem Description

If a family is too large, it is indeed not easy to tell whether two people are relatives. Now given a certain relatives graph, find the number of people in the family of any given person.

The rule is: if xx and yy are relatives, and yy and zz are relatives, then xx and zz are also relatives. If x,yx, y are relatives, then all of xx's relatives are also yy's relatives, and all of yy's relatives are also xx's relatives.

Input Format

The first line: three integers nn (n≤100,000n \le 100,000, m≤200,000m \le 200,000), representing nn people and mm pieces of information.

The following mm lines: each piece of information is in one of two forms:

  • M a b: means aa and bb are relatives.
  • Q a: requires outputting the number of people in the family of aa.

Output Format

Output the number of people in the family of aa.

Sample Input

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

Sample Output

1
1
3
1
4

Constraints

Time limit: 1s; memory limit: 1024 KiB for each test case.