Problem: You are standing in front of the room with great treasures. The only thing stopping you is the door with a push-button combination lock. This lock has d buttons with digits from 0 to d - 1. Whenever you press a button, it stays pushed down. You can not pop back up just one button, but there is a "RESET" button — pressing it pops up all other buttons. Initially, no buttons are pushed down.

The door instantly opens when some specific set of digits is pushed down. Sadly, you don't know the password for it. Having read the documentation for this specific lock, you found out that there are n possible passwords for this particular lock. 

Find the shortest sequence of button presses, such that all possible passwords appear at least once during its execution. Any shortest correct sequence of button presses will be accepted.

Input

The first line contains two integers d and n (1 ≤ d ≤ 10; 1 ≤ n ≤ 2^d - 1). Next n lines describe possible passwords. Each line contains a string s_i of d zeros and ones: for all j from 1 to d the j-th character is 1 iff the button with the digit j - 1 must be pushed down.

All strings s_i are different, and each string contains at least one 1.

Output

On the first line, print the number k — the minimum number of button presses. On the second line, print k tokens, describing the sequence. Whenever you press a button with a digit, print that digit. Whenever you press "RESET", print "R".

Examples

Input


2 2
10
11


Output


2
0 1 


Input


3 4
001
111
101
011


Output


6
2 0 R 1 2 0 

Note

In the second example, the sequence 1 2 R 2 0 1 is also possible.

Solution (in CPP):

Solution:
#include<bits/stdc++.h>

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double llf;
typedef std::pair<int,int> pii;

#define xx first
#define yy second

template<typename T> inline T max(T a,T b){return a>b?a:b;}
template<typename T> inline T min(T a,T b){return a<b?a:b;}
template<typename T> inline T abs(T a){return a>0?a:-a;}
template<typename T> inline bool repr(T &a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool repl(T &a,T b){return a>b?a=b,1:0;}
template<typename T> inline T gcd(T a,T b){T t;if(a<b){while(a){t=a;a=b%a;b=t;}return b;}else{while(b){t=b;b=a%b;a=t;}return a;}}
template<typename T> inline T sqr(T x){return x*x;}
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
#define I __attribute__((always_inline))inline
#define mset(a,b) memset(a,b,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

#define fo0(i,n) for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define fd0(i,n) for(int i=(n)-1;~i;i--)
#define fd1(i,n) for(int i=n;i;i--)
#define fd(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define foe(i,x)for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)

struct Cg{I char operator()(){return getchar();}};
struct Cp{I void operator()(char x){putchar(x);}};
#define OP operator
#define RT return *this;
#define UC unsigned char
#define RX x=0;UC t=P();while((t<'0'||t>'9')&&t!='-')t=P();bool f=0;\
if(t=='-')t=P(),f=1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define RL if(t=='.'){lf u=0.1;for(t=P();t>='0'&&t<='9';t=P(),u*=0.1)x+=u*(t-'0');}if(f)x=-x
#define RU x=0;UC t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'
#define TR *this,x;return x;
I bool IS(char x){return x==10||x==13||x==' ';}template<typename T>struct Fr{T P;I Fr&OP,(int&x)
{RX;if(f)x=-x;RT}I OP int(){int x;TR}I Fr&OP,(ll &x){RX;if(f)x=-x;RT}I OP ll(){ll x;TR}I Fr&OP,(char&x)
{for(x=P();IS(x);x=P());RT}I OP char(){char x;TR}I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS
(t)&&~t;t=P())*x++=t;}*x++=0;RT}I Fr&OP,(lf&x){RX;RL;RT}I OP lf(){lf x;TR}I Fr&OP,(llf&x){RX;RL;RT}I OP llf()
{llf x;TR}I Fr&OP,(uint&x){RU;RT}I OP uint(){uint x;TR}I Fr&OP,(ull&x){RU;RT}I OP ull(){ull x;TR}};Fr<Cg>in;
#define WI(S) if(x){if(x<0)P('-'),x=-x;UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
#define WL if(y){lf t=0.5;for(int i=y;i--;)t*=0.1;if(x>=0)x+=t;else x-=t,P('-');*this,(ll)(abs(x));P('.');if(x<0)\
x=-x;while(y--){x*=10;x-=floor(x*0.1)*10;P(((int)x)%10+'0');}}else if(x>=0)*this,(ll)(x+0.5);else *this,(ll)(x-0.5);
#define WU(S) if(x){UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
template<typename T>struct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}
I Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(38);RT}I Fw&OP,(ull x){WU(20);RT}I Fw&OP()
(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char*x){while(*x)P(*x++);RT}
I Fw&OP()(const char*x){while(*x)P(*x++);RT}I Fw&OP()(lf x,int y){WL;RT}I Fw&OP()(llf x,int y){WL;RT}};Fw<Cp>out;

namespace flow
{
	const int N=2300,M=33000,Nf=4095;

	struct edge
	{
		int to,w,ne,v;
	}e[M*2+2];
	
	int p[N+1],em=2,q[N<<1],qe,fa[N+1],dis[N+1];
	bool vis[N+1];
	
	int add(int a,int b,int w,int v)
	{
		//out,"add:",a,' ',b,' ',w,' ',v,'\n';
		e[em].to=b,e[em].w=w,e[em].v=v,e[em].ne=p[a],p[a]=em++;
		e[em].to=a,e[em].w=0,e[em].v=-v,e[em].ne=p[b],p[b]=em++;
		return em-1;
	}
	
	int fafa(int s,int t,int &cost)
	{
		cost=0;
		int flow=0;
		while(1)
		{
			memset(dis,0x3f,sizeof(dis));
			memset(fa,0x3f,sizeof(fa));
			dis[s]=0; 
			vis[s]=1;
			q[0]=s,qe=1;
			for(int i=0;i^qe;i++)
			{
				int k=q[i&Nf];
				for(int j=p[k];j;j=e[j].ne)
					if(e[j].w&&dis[e[j].to]>dis[k]+e[j].v)
					{
						dis[e[j].to]=dis[k]+e[j].v;
						fa[e[j].to]=j^1;
						if(!vis[e[j].to])q[(qe++)&Nf]=e[j].to,vis[e[j].to]=1;
					}
				vis[k]=0;
			}
			if(fa[t]==0x3f3f3f3f)break;
			int rfl=0x7fffffff;
			for(int i=t;i!=s;i=e[fa[i]].to)
				repl(rfl,e[fa[i]^1].w);
			cost+=dis[t]*rfl;
			flow+=rfl;
			for(int i=t;i!=s;i=e[fa[i]].to)
				e[fa[i]].w+=rfl,e[fa[i]^1].w-=rfl;
		}
		return flow;
	}
}

const int N=10,M=1<<N|5;

int n,d,ac,es,ed[M][N],ee[M],eu[M],ans[M*10];
char s[N+1];
bool req[M];

int&gw(int x){return flow::e[x].w;}

void dfs(int x)
{
	fo0(i,n)if(ed[x][i]&&gw(ed[x][i]))
	{
		ans[ac++]=i;
		gw(ed[x][i])--;
		return dfs(x|1<<i);
	}
	assert(gw(ee[x])--);
}

int main()
{
	in,n,d;
	fo0(i,d)
	{
		in,s;
		int t=0;
		fo0(j,n)t|=(s[j]-48)<<j;
		req[t]=1;
	}
	// 0 ~ 2^n-1 in, 2^n ~ 2^n*2-1 out
	// u=2^n*2, u=S, u+1=T, u+2=super-S, u+3=super-T
	int u=1<<n+1,m=1<<n;
	flow::add(u+1,u,m,0);
	es=flow::add(u,0,m,1);
	fo0(i,m)ee[i]=flow::add(i+m,u+1,1,0);
	fo0(i,m)
	{
		if(req[i])flow::add(i,u+3,1,0),eu[i]=flow::add(u+2,i+m,1,0);
		flow::add(i,i+m,m,0);
	}
	fo0(i,m)
	{
		fo0(j,n)if(~i>>j&1)
		{
			int k=i|1<<j;
			ed[i][j]=flow::add(i+m,k,m,1);
		}
	}
	int res;
	flow::fafa(u+2,u+3,res);
	out,res-1,'\n';
	//fo0(i,m)out,gw(eu[i]),' ';out,'\n';
	fo0(i,gw(es))
	{
		if(i!=0)ans[ac++]=-1;
		dfs(0);
	}
	assert(ac==res-1);
	fo0(i,ac)
	{
		if(ans[i]==-1)out,"R ";
		else out,ans[i],' ';
	}
	out,'\n';
}