#include<bits/stdc++.h>
using namespace std;
const int N=1<<11;
bool vis[N];
int match[N],nxt[N],pre[N];
vector<int> G[N];
bool find(int u){
	for(auto& v:G[u]){
		if(vis[v])continue;
		vis[v]=true;
		if(match[v]==-1||find(match[v])){
			match[v]=u,match[u]=v;
			return true;
		}
	}
	return false;
}
int main(){
	int d,n;cin>>d>>n;
	vector<vector<int>>layer(d+1);
	vector<int>v(n);
	for(int i=0;i<n;i++){
		string s;cin>>s;
		int one=0,res=0;
		for(auto& j:s){
			one+=j=='1';
			res=2*res+j-'0';
		}
		layer[one].push_back(i);
		v[i]=res;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j==i)continue;
			if((v[i]&v[j])==v[j]){
				G[j].push_back(i+n);
			}
		}
	}
	memset(match,-1,sizeof match);
	int ans=0;
	for(int i=d;i>=0;i--){
		for(auto& j:layer[i]){
			memset(vis,0,sizeof vis);
			ans+=find(j);	
		}
	}
	cerr<<ans<<endl;
	vector<int>start;
	memset(pre,-1,sizeof pre);
	memset(nxt,-1,sizeof nxt);
	for(int i=0;i<n;i++){
		if(match[i]!=-1){	
			pre[match[i]-n]=i;
			nxt[i]=match[i]-n;
		}
	}
	for(int i=0;i<n;i++){
		if(pre[i]==-1){
			start.push_back(i); 
		}
	}
	vector<char> res;
	while(!start.empty()){
		int cur=0;
		int ind=start.back();
		start.pop_back();
		while(ind!=-1){
			for(int j=0;j<d;j++){
				if(cur&(1<<j))continue;
				if(v[ind]&(1<<j)){
					//cout<<"???"<<j<<endl;
					res.emplace_back(d-j-1+'0');
				}
			}
			assert(__builtin_popcount(cur)<__builtin_popcount(v[ind]));
			cur=v[ind];
			ind=nxt[ind];
		}
		res.push_back('R');
	}
	assert(!res.empty());
	res.pop_back();
	cout<<res.size()<<endl;
	for(auto& i:res)cout<<i<<' ';
}