#include using namespace std; #define all(v) v.begin(),v.end() #define resort(v) sort(v.rbegin(),v.rend()) using ll = long long; using ull = unsigned long long; using vll=vector; using vvll = vector>; using P = pair; using vp=vector>; const ll inf=1ll<<60; #define mod10 (ll)1e9+7 #define mod99 (ll)998244353 const double PI = acos(-1); #define rep(i,n) for (ll i=0;i=0;--i) #define rep2(i,a,n) for (ll i=a;i=a;--i) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n >> m; vp e(m); ll u, v; rep(i, m) { cin >> u >> v; u--; v--; e[i] = {u, v}; } if(m%2==1) { cout << "-1\n"; return; } vvll g(n); for(auto[u, v]: e) { g[u].push_back(v); g[v].push_back(u); if(u==0&&v==n-1) { cout << "-1\n"; return; } } vector seen(n, false); vector itrvl(n, false); itrvl[n-1] = true; seen[0] = true; stack stk; stk.push(0); while(!stk.empty()) { ll p = stk.top(); stk.pop(); for(ll ni: g[p]) { if(itrvl[ni]) { itrvl[p] = true; } else if(!seen[ni]) { seen[ni] = true; stk.push(ni); } } } vector ans(m, '@'); ll cnt_b = 0; ll cnt_r = 0; rep(i, m) { auto [u, v] = e[i]; if(u==0 && seen[v]) { cnt_b += 1; ans[i] = 'B'; } else if(seen[u] && v == n-1) { cnt_r += 1; ans[i] = 'R'; } } if(cnt_b>m/2 || cnt_r>m/2) { cout << "-1\n"; return; } else { rep(i, m) { if(ans[i] == '@') { if(cnt_b < m/2) { ans[i] ='B'; cnt_b += 1; } else ans[i] = 'R'; } } rep(i, m) { cout << ans[i]; } cout << '\n'; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int t=1; //cin >> t; while(t--)solve(); }