#include <bits/stdc++.h>
using ll = long long;
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n , q;
    std::cin >> n >> q;
    std::vector<ll> arr(n);
    while(q--){
        char cha;
        ll a , b;
        std::cin >> cha >> a >> b;
        --a;
        --b;
        if(cha == 'Q'){
            if(arr[a] == 1 and arr[b] == 1 ){
                std::cout << "R\n";
            }
           else if(arr[a] == 1 and arr[b] == -1 ){
                std::cout << "A\n";
            }
            else if(arr[a] == -1 and arr[b] == -1 ){
                std::cout << "R\n";
            }
           else if(arr[a] == 0 and arr[b] == 0 ){
                std::cout << "?\n";
            }
           else if(arr[a] != 0 and arr[b] == 0 ){
                std::cout << "?\n";
            }
           else if(arr[a] == 0 and arr[b] != 0 ){
                std::cout << "?\n";
            }
        }
        else if( cha == 'A'){
               if(arr[a] == 0 and arr[b] == 0 ){
                arr[a] = 1;
                arr[b] = -1;
            }
           else if(arr[a] != 0 and arr[b] == 0 ){
               arr[b] = -1*arr[a];
            }
            else if(arr[a] == 0 and arr[b] != 0 ){
                 arr[a] = -1*arr[b];
            }
         
          }
        
          else{
            if(arr[a] == 0 and arr[b] == 0 ){
                arr[a] = 1;
                arr[b] = -1;
            }
           else if(arr[a] != 0 and arr[b] == 0 ){
               arr[b] = arr[a];
            }
            else if(arr[a] == 0 and arr[b] != 0 ){
                 arr[a] = arr[b];
            }
        }
}
        }
    
    
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |