#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 m_parentsOrSize; }; void solve() { int n, m; cin >> n >> m; if(m%2==1) { cout << "-1\n"; return; } vp e(m); ll u, v; rep(i, m) { cin >> u >> v; u--; v--; e[i] = {u, v}; } vvll g(n); UnionFind uf(n); for(auto[u, v]: e) { g[u].push_back(v); g[v].push_back(u); uf.merge(u, v); if((u==0&&v==n-1) || (v==0&&u==n-1)) { cout << "-1\n"; return; } } if(!uf.connected(0, n-1)) { string ans = ""; rep(i, m) ans += (i%2==0) ? 'B' : 'R'; cout << ans << "\n"; } 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(auto 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 || v==0) { cnt_b += 1; ans[i] = 'B'; } else if(u == n-1 || v == n-1) { cnt_r += 1; ans[i] = 'R'; } } if(cnt_b>n/2 && cnt_r>n/2) { cout << "-1\n"; return; } else { rep(i, m) { if(ans[i] == '@') { if(cnt_b < n/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(); }