#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
vector <int > layer[11];
vector<int > ans;
/*
先分层，然后边分层边用跑dinic 
*/ 
int dep[maxn],pre[maxn],now[maxn],num[maxn];
struct edge{
	int u;
	int v;
	int w;
	int next;
}e[maxn<<3];
int d,n,cnt=0,T,S,head[maxn];
queue<int> q;
void ini(){
	T=2*n+1;
	S=2*n+2;
	memset(head,-1,sizeof(head));
	memset(pre,0,sizeof(pre));
	cnt=-1;
}
void adde(int u,int v){//存双边
	 e[++cnt].v=v;
	 e[cnt].next=head[u];
	 e[cnt].w=1;
	 head[u]=cnt;
	 e[++cnt].v=u;
	 e[cnt].next=head[v];
	 e[cnt].w=0;
	 head[v]=cnt;
}
bool bfs(){
	memset(dep,0,sizeof(dep));
	q.push(S);
	dep[S]=1;
	int u;
	while(q.size()){
		u=q.front();
		q.pop();
		now[u]=head[u];
		int i;
		for(i=head[u];~i;i=e[i].next){
			int v=e[i].v,w=e[i].w;
			if(dep[v]||w==0)continue;
			dep[v]=dep[u]+1;
			q.push(v); 
		}
	}
	return dep[T];
}
int dfs(int u,int flow){
	if(u==T)return flow;
	for(int i=now[u];~i;i=e[i].next){
		now[u]=i;
		int v=e[i].v,w=e[i].w;
		if(!w||dep[v]!=dep[u]+1)continue;//
		int t=dfs(v,min(flow,w));
		if(!t)continue;
		e[i].w-=t;
		e[i^1].w+=t;
		pre[u]=v;
		return t;
	}
	return 0;
}
int main(){
	
	cin>>d>>n;
	string s;
	for(int i=1;i<=n;i++){
		cin>>s;
		for(int j=d-1;j>=0;j--){//1011 13 1101 001 4
		num[i]<<=1;
		if(s[j]=='1'){
			num[i]+=1;}
		}
		layer[__builtin_popcount(num[i])].push_back(i);
	}
	ini();
	
	
	for(int i=1;i<=n;i++){
		adde(S,i);
		adde(i+n,T);
	}
	
	
	for(int i=d;i>0;i--){//从高层开始dinic 贪心 
		for(int j=i+1;j<=d;j++){
			for(int high:layer[j])
			for(int low:layer[i]){
				if((num[low]&num[high])==num[low])
				adde(low,high+n);//low->high 
			}
		}
		while(bfs()){
			dfs(S,INF);
		}
	}
	int k,t1,t2,tp,diff;
	pre[0]=-1;
	for(int i=1;i<=d;i++)
	for(int j:layer[i]){
		if(pre[j]==-1)continue;
		k=j;
		tp=0;
		while(k>=0){
			diff=tp^num[k];
			tp=num[k];
			for(int j_=0;j_<d;j_++){
				if((diff>>j_)&1)ans.push_back(j_);
			}
			t1=k;
			t2=k+n;
			k=pre[k]-n;
			pre[t1]=pre[t2]=-1; 
		}
		ans.push_back(-1);
	}
	int res=ans.size()-1;
	cout<<res<<endl;
	for(int i=0;i<res;i++){
		if(ans[i]==-1)	cout<<"R"<<" ";
		else cout<<ans[i]<<" ";
	}
	return 0;
}