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:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define fljbgjhbgfbjbr
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define N 2100
using namespace std;
namespace ywy{
	typedef struct _b{
		int dest;int nxt;int len;int c;
	}bian;bian memchi[100000];
	int gn=2,heads[N],mincol[N],bv[N],que[100000],dis[N],gj[N],pre[N];
	inline void add(int s,int t,int l,int c){
		memchi[gn].dest=t;memchi[gn].len=l;memchi[gn].c=c;memchi[gn].nxt=heads[s];heads[s]=gn;gn++;	
	}
	inline int spfa(int s,int t){
		memset(dis,0x3f,sizeof(dis));
		int head=0,tail=1;
		mincol[que[0]=s]=1234567890;
		dis[s]=0;
		while(head<tail){
			int me=que[head++]; bv[me]=0;
			for(int i=heads[me];i;i=memchi[i].nxt){
				if(!memchi[i].c)continue;
				if(dis[me]+memchi[i].len<dis[memchi[i].dest]){
					dis[memchi[i].dest]=dis[me]+memchi[i].len;
					pre[memchi[i].dest]=i;
					mincol[memchi[i].dest]=min(mincol[me],memchi[i].c);
					if(!bv[memchi[i].dest])bv[que[tail++]=memchi[i].dest]=1;
				}
			}
		}
		if(dis[t]==dis[0]) return(dis[0]);
		int ans=dis[t]*mincol[t],cur=t;
		while(cur!=s){
			int me=pre[cur];memchi[me].c-=mincol[t];memchi[me^1].c+=mincol[t];cur=memchi[me^1].dest;
		}
		return ans;
	}
	namespace euler{
		typedef struct _b{
			int dest;int nxt;char c;int vis;
		}bian;bian memchi[100001];int gn=1,heads[N];
		inline void add(int s,int t,char c){
			memchi[gn].dest=t;memchi[gn].c=c;memchi[gn].nxt=heads[s];heads[s]=gn;gn++;	
		}
		void solve(int pt,vector<char> &vec){
			for(int i=heads[pt];i;i=memchi[i].nxt){
				if(memchi[i].vis) continue;
				memchi[i].vis=1;
				solve(memchi[i].dest,vec);
				vec.push_back(memchi[i].c);	
			}
		}
	}
	void ywymain(){
		int d,n; cin>>d>>n;
		int cnt=0;
		for(int i=1;i<=n;i++){
			char str[12]; cin>>str;
			int x=0;
			for(int j=0;j<d;j++)x=x*2+str[j]-'0';
			if(!x)continue;
			gj[x]=1; cnt++;
		}
		if(!cnt){
			cout<<0<<endl; return;	
		}
		int s=(1<<d)*2+1,t=s+1;
		add(s,1,0,1); add(1,s,0,0);
		add(s,1,1,1234567890); add(1,s,-1,0);
		for(int i=0;i<(1<<d);i++){
			if(gj[i]){
				add(s,i+1,0,1); add(i+1,s,0,0);
				add(i+(1<<d)+1,t,0,1); add(t,i+(1<<d)+1,0,0);
			}	
			for(int j=0;j<d;j++){
				if(!(i&(1<<j))){
					add(i+1,i+(1<<j)+(1<<d)+1,1,1234567890);
					add(i+(1<<j)+(1<<d)+1,i+1,-1,0);
					add(i+(1<<d)+1,i+(1<<j)+(1<<d)+1,1,1234567890);
					add(i+(1<<j)+(1<<d)+1,i+(1<<d)+1,-1,0);
				}
			}
		}
		int ans=0;
		while(1){
			int x=spfa(s,t);
			if(x==0x3f3f3f3f)break;
			ans+=x;	
		}
		for(int i=0;i<(1<<d);i++){
			if(gj[i]){
				for(int j=heads[i+1];j;j=memchi[j].nxt){
					if(memchi[j].dest==s&&!memchi[j].c){
						euler::add(i,0,'R'); break;	
					}
				}
			}
			for(int j=heads[i+1];j;j=memchi[j].nxt){
				if((j&1)||memchi[j].dest==t||memchi[j].dest==s) continue;
				char op;
				for(int k=0;k<d;k++){
					if(!(i&(1<<k))&&((memchi[j].dest-(1<<d)-1)&(1<<k))) op=d-k-1+'0';	
				}
				for(int k=0;k<memchi[j^1].c;k++) euler::add(i,memchi[j].dest-(1<<d)-1,op);	
			}
			for(int j=heads[i+(1<<d)+1];j;j=memchi[j].nxt){
				if((j&1)||memchi[j].dest==t||memchi[j].dest==s) continue;
				char op;
				for(int k=0;k<d;k++){
					if(!(i&(1<<k))&&((memchi[j].dest-(1<<d)-1)&(1<<k))) op=d-k-1+'0';	
				}
				for(int k=0;k<memchi[j^1].c;k++) euler::add(i,memchi[j].dest-(1<<d)-1,op);	
			}
			
		}
		vector<char> vec;
		euler::solve(0,vec);
		cout<<vec.size()-1<<endl;
		for(int i=(int)vec.size()-1;i>=1;i--) cout<<vec[i]<<" ";
	}
}
int main(){
	ywy::ywymain();
	return 0;	
}