#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);
    arr[0] = 1;
    while(q--){
        char t; 
        ll a , b;
        std::cin >> t >> a >>b;
        --a; 
        --b;
       if(t == '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 << "A\n";
            }
           else if(arr[a] == -1 and arr[b] == -1 ){
                std::cout << "R\n";
            }
           else if(arr[a] == 1 and arr[b] == 0 ){
                std::cout << "?\n";
            }
           else if(arr[a] == 0 and arr[b] == 1){
                std::cout << "?\n";
            }
       }
       else if(t == 'A'){
        if(arr[a] == 1){
            arr[b] = -1;
        }
        else{
            arr[a] = -1;
        }
    }
        if(t == 'R'){
         if(arr[a] == 1){
            arr[b] = 1;
        }
        else{
            arr[a] = 1;
        }
        }
       }
    }
   
    
    
| # | 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... |