# NOI2007.Day2.T3.追捕盗贼

//Lib
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<ctime>

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
//Macro
#define rep(i,a,b) for(int i=a,tt=b;i<=tt;++i)
#define drep(i,a,b) for(int i=a,tt=b;i>=tt;--i)
#define erep(i,e,x) for(int i=x;i;i=e[i].next)
#define irep(i,x) for(__typedef(x.begin()) i=x.begin();i!=x.end();i++)
#define sqr(x) ((x)*(x))
#define pb push_back
#define PS system("pause");
typedef long long ll;
typedef pair<int,int> pii;
const int oo=~0U>>1;
const double inf=1e20;
const double eps=1e-6;
string name="",in=".in",out=".out";
//Var
struct W
{
int x,y;char order;
}way[20008];
struct E
{
int next,node;
}e[2008];
int cnt,n,ans=oo,as,tot;
int h[1008],f[1008];
void Land(int x){way[++cnt].order='L';way[cnt].x=x;}
void Back(int x){way[++cnt].order='B';way[cnt].x=x;}
void Move(int x,int y){way[++cnt].order='M';way[cnt].x=x;way[cnt].y=y;}
void TDP(int x,int fa)
{
int maxx=0,msize=0,son=0,y;
erep(i,e,h[x])
{
if((y=e[i].node)!=fa)
{
TDP(y,x);
if(f[y]==maxx)msize++;
if(f[y]>maxx)maxx=f[y],msize=1;
++son;
}
}
if(msize>1)f[x]=maxx+1;else f[x]=maxx;
if(son==0)f[x]++;
}
void Solve(int x,int fa,int t,int d)
{
int maxx=0,msize=0,son=0,mnum=-1,y;
erep(i,e,h[x])
{
if((y=e[i].node)!=fa)
{
Solve(y,x,0,0);
if(f[y]==maxx)msize++;
if(f[y]>maxx)maxx=f[y],msize=1,mnum=y;
++son;
}
}
if(d==1)
{
erep(i,e,h[x])
if((y=e[i].node)!=fa)
{
if(y!=mnum)
{
Land(x);
Move(x,y);
Solve(y,x,1,1);
}
}
if(son==0){Back(x);return;}
Move(x,mnum);Solve(mnum,x,1,1);
}
if(msize>1)f[x]=maxx+1;else f[x]=maxx;
if(son==0)f[x]++;
}
void Work()
{
scanf("%d",&n);int a,b;
rep(i,1,n)
{
memset(f,0,sizeof f);
TDP(i,0);
if(f[i]<ans)ans=f[i],as=i;
}
printf("%d\n",ans);
memset(f,0,sizeof f);
Land(as);Solve(as,0,1,1);
}
void Outit()
{
printf("%d\n",cnt);
rep(i,1,cnt)
{
if(way[i].order=='M')printf("%c %d %d\n",way[i].order,way[i].x,way[i].y);
else printf("%c %d\n",way[i].order,way[i].x);
}
}
int main()
{
//	freopen((name+in).c_str(),"r",stdin);
//	freopen((name+out).c_str(),"w",stdout);
//	Init();
Work();
Outit();
return 0;
}