/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest
9. module on time
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
int n,m,U[305],V[305],col[305],perm[305];
int fa[105];
int find(int x)
{
if(fa[x]==x) return x;
return fa[x]=find(fa[x]);
}
void merge(int x,int y)
{
int xx=find(x),yy=find(y);
if(xx!=yy) fa[xx]=yy;
}
mt19937 rnd(114514);
int vis[105][2];
vector <pii > g[105];
bool chk()
{
for(int i=1;i<=n;i++) g[i].clear();
for(int i=1;i<=m;i++) g[U[i]].pb(mp(V[i],col[i])),g[V[i]].pb(mp(U[i],col[i]));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) vis[j][0]=vis[j][1]=0;
vis[i][0]=vis[i][1]=1;
queue <pii > q;
q.push(mp(i,0)),q.push(mp(i,1));
while(q.size())
{
int u=q.front().fi,c=q.front().se;
q.pop();
for(int j=0;j<g[u].size();j++) if(g[u][j].se!=c)
{
int v=g[u][j].fi;
if(vis[v][c^1]) continue;
vis[v][c^1]=1,q.push(mp(v,(c^1)));
}
}
for(int j=1;j<=n;j++) if(!vis[j][0]&&!vis[j][1]) return 0;
}
return 1;
}
int tr[305],dep[305];
void dfs0(int u,int par)
{
for(int i=0;i<g[u].size();i++)
{
int v=g[u][i].fi;
if(v==par) continue;
dep[v]=dep[u]+1,dfs0(v,u);
}
}
bool work()
{
for(int i=1;i<=n;i++) fa[i]=i,g[i].clear(),dep[i]=0;
for(int i=1;i<=m;i++) perm[i]=i,tr[i]=0;
for(int i=m;i>=1;i--) swap(perm[i],perm[1+rnd()%i]);
for(int i=1;i<=m;i++)
{
int x=perm[i];
if(find(U[x])!=find(V[x])) merge(U[x],V[x]),tr[x]=1,g[U[x]].pb(mp(V[x],x)),g[V[x]].pb(mp(U[x],x));
}
dfs0(1+rnd()%n,-1);
for(int i=1;i<=m;i++)
{
if(tr[i]) col[i]=min(dep[U[i]],dep[V[i]])%2;
else
{
col[i]=rnd()%2;
int x=U[i],y=V[i];
if(rnd()%2) swap(x,y);
col[i]=(dep[x]%2)^1;
}
}
// for(int i=1;i<=m;i++) cout<<col[i];
// cout<<"\n";
// system("pause");
if(chk())
{
for(int i=1;i<=m;i++) cout<<(col[i]?"R":"B");
cout<<"\n";
return 1;
}
return 0;
}
void solve()
{
cin>>n>>m;
for(int i=1;i<=m;i++) cin>>U[i]>>V[i];
for(int _=0;_<30000;_++) if(work()) return;
cout<<"IMPOSSIBLE\n";
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int _=1;
cin>>_;
while(_--) solve();
return 0;
}/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest
9. module on time
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
int n,m,U[305],V[305],col[305],perm[305];
int fa[105];
int find(int x)
{
if(fa[x]==x) return x;
return fa[x]=find(fa[x]);
}
void merge(int x,int y)
{
int xx=find(x),yy=find(y);
if(xx!=yy) fa[xx]=yy;
}
mt19937 rnd(114514);
int vis[105][2];
vector <pii > g[105];
bool chk()
{
for(int i=1;i<=n;i++) g[i].clear();
for(int i=1;i<=m;i++) g[U[i]].pb(mp(V[i],col[i])),g[V[i]].pb(mp(U[i],col[i]));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) vis[j][0]=vis[j][1]=0;
vis[i][0]=vis[i][1]=1;
queue <pii > q;
q.push(mp(i,0)),q.push(mp(i,1));
while(q.size())
{
int u=q.front().fi,c=q.front().se;
q.pop();
for(int j=0;j<g[u].size();j++) if(g[u][j].se!=c)
{
int v=g[u][j].fi;
if(vis[v][c^1]) continue;
vis[v][c^1]=1,q.push(mp(v,(c^1)));
}
}
for(int j=1;j<=n;j++) if(!vis[j][0]&&!vis[j][1]) return 0;
}
return 1;
}
int tr[305],dep[305];
void dfs0(int u,int par)
{
for(int i=0;i<g[u].size();i++)
{
int v=g[u][i].fi;
if(v==par) continue;
dep[v]=dep[u]+1,dfs0(v,u);
}
}
bool work()
{
for(int i=1;i<=n;i++) fa[i]=i,g[i].clear(),dep[i]=0;
for(int i=1;i<=m;i++) perm[i]=i,tr[i]=0;
for(int i=m;i>=1;i--) swap(perm[i],perm[1+rnd()%i]);
for(int i=1;i<=m;i++)
{
int x=perm[i];
if(find(U[x])!=find(V[x])) merge(U[x],V[x]),tr[x]=1,g[U[x]].pb(mp(V[x],x)),g[V[x]].pb(mp(U[x],x));
}
dfs0(1+rnd()%n,-1);
for(int i=1;i<=m;i++)
{
if(tr[i]) col[i]=min(dep[U[i]],dep[V[i]])%2;
else
{
col[i]=rnd()%2;
// int x=U[i],y=V[i];
// if(rnd()%2) swap(x,y);
// col[i]=(dep[x]%2);
}
}
// for(int i=1;i<=m;i++) cout<<col[i];
// cout<<"\n";
// system("pause");
if(chk())
{
for(int i=1;i<=m;i++) cout<<(col[i]?"R":"B");
cout<<"\n";
return 1;
}
return 0;
}
void solve()
{
cin>>n>>m;
for(int i=1;i<=m;i++) cin>>U[i]>>V[i];
for(int _=0;_<30000;_++) if(work()) return;
cout<<"IMPOSSIBLE\n";
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int _=1;
cin>>_;
while(_--) solve();
return 0;
}