#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;	
}