시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

문제

There are N charged particles, each with either a positive or a negative charge. The charge on each particle is unknown, but it is known that if two particles with the same charge are brought close together, they will repel each other and if two particles with a different charge are brought together, they will attract each other.

In an experiment, Q events happen in chronological order. Each event is of one of the following 2 types:

  1. Two particles are brought close together and you are told whether they repel or attract,
  2. You are asked when two particles are brought together, whether they will repel, attract or either is possible, based on the experimental observations so far.

It is guaranteed that there is at least one configuration of particles that match all the experimental observations given.

입력

Your program must read from standard input.

The input starts with a line with 2 integers, N and Q. N denotes the number of charged particles, Q denotes the number of events.

Q lines will then follow with 1 character and 2 integers each, the ith line will contain Ti, Ai and Bi. If Ti = ‘A’, it denotes type 1 event where particles Ai and Bi attract. If Ti = ‘R’, it denotes type 1 event where particles Ai and Bi repel. If Ti = ‘Q’, it denotes type 2 event asking whether particles Ai and Bi attract or repel (or either is possible).

출력

Your program must print to standard output.

For every type 2 event, your program must output one line with one character. Output ‘A’ if the charges will attract, ‘R’ if the charges will repel, or ‘?’ if either is possible.

제한

  • 1 ≤ N, Q ≤ 105
  • 1 ≤ Ai ≠ Bi ≤ N
  • Ti = ‘A’, ‘R’, or ‘Q’

예제 입력 1

2 3
Q 1 2
R 1 2
Q 1 2

예제 출력 1

?
R

예제 입력 2

4 5
R 1 2
A 2 3
A 1 4
Q 2 4
Q 1 3

예제 출력 2

A
A