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>
using namespace std;
int d,n,flag;
#define inf 2e9
#define N 3100
#define M 2010000
int hed[N],dis[N],mn[N],pre[N],bh[N],tot=1,s,t,mxfl,mincost; 
bool in[N];
struct edg{
	int to,nxt,f,v;
}e[M];
void add(int x,int y,int f,int v){
//	printf("%d %d %d %d\n",x,y,f,v);
	e[++tot]=(edg){y,hed[x],f,v};hed[x]=tot;
	e[++tot]=(edg){x,hed[y],0,-v};hed[y]=tot;
}
void dfs(int x){
	e[bh[x]].f-=mn[t];
	e[bh[x]^1].f+=mn[t];
	if(pre[x]!=s)	dfs(pre[x]);
}
queue<int>q;
bool spfa(){
//	memset(dis,0x3f,sizeof(dis));
	for(int i=1;i<=t;i++)	dis[i]=inf;
	dis[s]=0;
	mn[s]=inf;
	q.push(s);
	while(!q.empty()){
		int x=q.front();q.pop();
		in[x]=0;
		for(int i=hed[x];i;i=e[i].nxt){
			int to=e[i].to;
			if(dis[to]>dis[x]+e[i].v && e[i].f>0){
				dis[to]=dis[x]+e[i].v;
				mn[to]=min(mn[x],e[i].f);
				pre[to]=x;
				bh[to]=i;
				if(!in[to])	q.push(to),in[to]=1;
			}
		}
	}
	if(dis[t]==inf)	return 0;
	dfs(t);
	return 1;
}
void ek(){
	mxfl=0;
	mincost=0;
	while(spfa()){
		mincost+=dis[t]*mn[t];
		mxfl+=mn[t];
	}
}
char ch[N][N]; 
int a[N],cnt;
int main(){
	scanf("%d%d",&d,&n);
	s=2*n+2;t=s+1;
	add(s,2*n+1,inf,0);
	for(int i=1;i<=n;i++)
		scanf("%s",ch[i]);
	for(int i=1;i<=n;i++){
		flag=0;
		for(int k=0;k<d;k++)	if(ch[i][k]=='1')	flag++;
		add(2*n+1,i+n,1,flag+1);
		add(s,i,1,0);
		add(i+n,t,1,0);
		for(int j=1;j<=n;j++){
			flag=0;
			for(int k=0;k<d && flag>=0;k++){
				if(ch[i][k]=='0' && ch[j][k]=='1')	flag=-inf;
				if(ch[i][k]=='1' && ch[j][k]=='0')	flag++;
			}
			if(flag>0)
				add(j,i+n,1,flag);
			
		} 
	}
	ek();
	printf("%d\n",mincost-1);
	for(int i=hed[2*n+1];i;i=e[i].nxt){
		int to=e[i].to;
		if(e[i].f==0)
			a[++cnt]=to-n;
	}
	for(int i=1;i<=cnt;i++){
		if(i!=1)	printf("R ");
		for(int j=0;j<d;j++)
			if(ch[a[i]][j]=='1')
				printf("%d ",j);
		int now=a[i];
		flag=1;
		while(flag){
			flag=0;
			for(int j=hed[now];j;j=e[j].nxt){
				int to=e[j].to;
				if(e[j].f==0 && e[j].v>0){
					flag=1;
					for(int k=0;k<d;k++){
						if(ch[to-n][k]=='1' && ch[now][k]=='0')
							printf("%d ",k);
					}
					now=to-n;
					break;
				}
			}
		}
	}
	return 0;	
}