/*
Author: Nguyen Chi Thanh - High School for the Gifted - VNU.HCM (i2528)
*/
#include <bits/stdc++.h>
using namespace std;
/* START OF TEMPALTE */
// #define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(x) (1ll << (x))
#define SZ(a) ((int32_t)a.size())
#define debug(a, l, r) {for (int _i = (l); _i <= (r); ++_i) cout << (a)[_i] << ' '; cout << '\n';}
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (x > y) {
x = y;
return true;
} else return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (x < y) {
x = y;
return true;
} else return false;
}
/* END OF TEMPALTE */
struct DSU {
int n;
vector<int> par, val;
vector<vector<int>> vertices;
DSU(int _n) : n(_n), par(n + 5, 0), val(n + 5, 0) {
iota(all(par), 0);
vertices.resize(n + 5, vector<int>());
for (int i = 1; i <= n; ++i)
vertices[i].push_back(i);
}
int findSet(int u) {
if (u == par[u]) return u;
return par[u] = findSet(par[u]);
}
void unite(int u, int v, int delta) {
int x = findSet(u);
int y = findSet(v);
if (x == y) return;
if (SZ(vertices[x]) < SZ(vertices[y])) {
swap(u, v);
swap(x, y);
}
for (auto k : vertices[y])
vertices[x].push_back(k);
par[y] = x;
if ((val[u] ^ val[v]) != delta) {
for (auto k : vertices[y])
val[k] ^= 1;
}
}
bool same(int u, int v) {
return findSet(u) == findSet(v);
}
};
void solve() {
int n, q; cin >> n >> q;
DSU dsu(n);
while (q--) {
char type; int u, v;
cin >> type >> u >> v;
if (type == 'A')
dsu.unite(u, v, 1);
else if (type == 'R')
dsu.unite(u, v, 0);
else {
if (!dsu.same(u, v)) {
cout << '?' << '\n';
} else {
cout << ((dsu.val[u] ^ dsu.val[v]) ? 'A' : 'R') << '\n';
}
}
}
}
signed main() {
#ifdef NCTHANH
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(nullptr); cout.tie(nullptr);
solve();
return 0;
}