#P118. [KSC001D] A problem about charges
[KSC001D] A problem about charges
## Source
**This problem is adapted from [Long Long OJ](https://www.llong.tech/). All rights reserved by NOISG.**
**Problem source: <https://github.com/noisg/sg_noi_archive/tree/master/2019_prelim> (Task 3)**
**Materials compiled by [](/user/27).**
## Problem Description
There are $N$ charged particles. **Particles with opposite charges attract each other, while particles with the same charge repel each other.**
There are $Q$ operations, each represented as $T_i,A_i,B_i$, which can be divided into three types based on $T_i$:
- Operation $\tt A$ means $A_i$ and $B_i$ **attract** each other.
- Operation $\tt R$ means $A_i$ and $B_i$ **repel** each other.
- Operation $\tt Q$ asks what would happen if $A_i$ and $B_i$ are placed together, given the current information.
For each $\tt Q$ operation, if it is **determined that they attract**, output $\tt A$; if **determined that they repel**, output $\tt R$; if it cannot be determined, output $\tt ?$.
It is guaranteed that there is at least one possible configuration where all operations are consistent.
## Input Format
The first line contains two integers $N$ and $Q$.
The next $Q$ lines each contain a character $T_i$ and two integers $A_i,B_i$, representing an operation.
## Output Format
Several lines, each representing the answer to a $\tt Q$ operation.
## Samples
```input1
2 3
Q 1 2
R 1 2
Q 1 2
?
R
4 5
R 1 2
A 2 3
A 1 4
Q 2 4
Q 1 3
A
A
Sample 1 Explanation
For the first query, the relationship between and cannot be determined, so output .
For the second query, it is determined that and repel each other, so output .
Data Range
| Points | |||
|---|---|---|---|
| None | |||
| None | or | ||
| can only be or | |||
| All queries occur after all relationships are given | |||
| None | |||
| None |
For of the data:
- .
- .
- can only be , , or .