#include <bits/stdc++.h>
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;
typedef int Long;
 
const Long BT = 10;
const Long MX = (1<<BT) * 2 + 10;
const Long INF = 1e9;
 
struct Edge{
	Long from, to, cap, flow, cost;
	Edge *rev;
	Edge(): rev(NULL){}
	Edge(Long from, Long to, Long cap, Long cost): from(from), to(to), cap(cap), flow(0), cost(cost), rev(NULL) {}
};
 
struct Path{
	Long node, weight;
	Path(){}
	Path(Long node, Long weight) : node(node), weight(weight) {}
	bool operator>(const Path &P) const{ return weight > P.weight; }
};
 
Long mejorFlujazo;
Long sumBits = 0;
struct Graph{
	vector<Edge*> adj[MX];
	Edge *parent[MX];
	Long pot[MX];
	bool inQueue[MX];
	
	void clear(Long N = MX){
		for(Long i = 0; i < N; i++){
			adj[i].clear(),
			parent[i] = NULL;
			pot[i] = 0;
			inQueue[i] = false;
		}
	}
	
	void addEdge(Long u, Long v, Long w, Long cost){
		Edge *forward = new Edge(u, v, w, cost);
		Edge *backward = new Edge(v, u, 0, -cost);
		forward->rev = backward;
		backward->rev = forward;
		adj[u].pb(forward);
		adj[v].pb(backward);
	}
	
	void spfa(Long s, Long n){
		for(Long i = 0; i < n; i++) pot[i] = INF;
		queue<Long> q;
		pot[s] = 0;
		inQueue[s] = true;
		q.push(s);
		while(!q.empty()){
			Long u = q.front();
			q.pop();
			inQueue[u] = false;
			for(Edge *e : adj[u]){
				Long v = e->to;
				if(e->cap - e->flow > 0 && pot[u] + e->cost < pot[v]){
					pot[v] = pot[u] + e->cost;
					if(!inQueue[v]) q.push(v);
					inQueue[v] = true;
				}
			}
		}
	}
	
	pair<Long,Long> dijkstra(Long s, Long t, Long n){
		priority_queue<Path,vector<Path>, greater<Path>> q;
		
		vector<Long> d(n,INF);
		vector<Long> residualCap(n,0);
		d[s] = 0;
		residualCap[s] = INF;
		q.push(Path(s, d[s]));
		
		while(!q.empty()){
			Path p = q.top();
			q.pop();
			Long u = p.node;
			if(p.weight != d[u]) continue;
			
			for(Edge *e : adj[u]){
				Long v = e->to;
				Long cf = e->cap - e->flow;
				Long cost = e->cost + pot[u] - pot[v];
				
				if(cf > 0 && d[u] + cost < d[v]){
					d[v] = d[u] + cost;
					q.push(Path(v,d[v]));
					residualCap[v] = min(residualCap[u], cf);
					parent[v] = e;
				}
			}
		}
		if(d[t] == INF) return {0,0};
		for(Long i = 0; i < n; i++) pot[i] += d[i];
		
		Long cf = residualCap[t];
		Long cur = t;
		while(true){
			parent[cur]->flow += cf;
			parent[cur]->rev->flow -= cf;
			cur = parent[cur]->from;
			if(cur == s) break;
		}
		return {cf, pot[t] * cf};
	}
	
	pair<Long,Long> minCostFlow(Long s, Long t, Long n){
		spfa(s,n);
		pair<Long,Long> inc;
		pair<Long,Long> ans = {0,0};
		Long mejorFlujo = 0;
		Long costo = 0;
		// minCost - Flujo;
		Long prevCost = INF;
		if(mejorFlujazo == -1){
			do{
				inc = dijkstra(s,t,n);
				ans.first += inc.first;
				ans.second += inc.second;
				assert(ans.second <= prevCost);
				prevCost = ans.second;
				if(costo > ans.second - ans.first){
					costo = ans.second - ans.first;
					
					mejorFlujo = ans.first;
				}
			}while(inc.first > 0);
			mejorFlujazo = mejorFlujo;
			/*debug(n);
			debug(costo);
			debug(sumBits);
			debug(costo + (n - 2) / 2 + sumBits - 1);*/
		}else{
			for(Long i = 0; i < mejorFlujazo; i++){
				inc = dijkstra(s,t,n);
				ans.first += inc.first;
				ans.second += inc.second;
			}
		}
		return ans;
	}
} G;
 
vector<Long> cnt;
vector<Long> numbers;
vector<Long> adj[MX];
bool used[MX];
vector<Long> ans;
 
void dfs(Long u, Long n, Long d){
	for(Long v : adj[u]){
		if(u == n) ans.push_back(-1);
		Long mn = numbers[u];
		Long mx = numbers[v];
		Long msk = (mx ^ mn);
		for(Long i = 0; i < d; i++) if(((msk>>i)&1) == 1) ans.push_back(i);
		dfs(v,n,d);
	}
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;
	
	Long d, n;
	cin >> d >> n;
	
	string cad;
	for(Long i = 0; i < n; i++){
		cin >> cad;
		Long num = 0;
		for(Long j = 0; j < d; j++){
			if(cad[j] == '1') num |= (1<<j);
		}
		numbers.push_back(num);
		cnt.push_back(__builtin_popcount(num));
		sumBits += cnt.back();
	}
	Long tot = 2*n+2;
	Long s = 2*n;
	Long t = 2*n + 1;
	
	for(Long i = 0; i < n; i++) G.addEdge(s,i,1,0);
	for(Long i = 0; i < n; i++) G.addEdge(i+n,t,1,0);
	for(Long i = 0; i < n; i++){
		for(Long j = 0; j < n; j++){
			if(i == j) continue;
			if((numbers[j] & numbers[i]) == numbers[j]){
				G.addEdge(i,j+n,1,-cnt[j]);
			}
		}
	}
	mejorFlujazo = -1;
	pair<Long,Long> aux = G.minCostFlow(s,t,tot);
	
	G.clear();
	for(Long i = 0; i < n; i++) G.addEdge(s,i,1,0);
	for(Long i = 0; i < n; i++) G.addEdge(i+n,t,1,0);
	for(Long i = 0; i < n; i++){
		for(Long j = 0; j < n; j++){
			if(i == j) continue;
			if((numbers[j] & numbers[i]) == numbers[j]){
				G.addEdge(i,j+n,1,-cnt[j]);
			}
		}
	}
	aux = G.minCostFlow(s,t,tot);
	//cout << aux.first << " " << aux.second << endl;
	
	for(Long i = 0; i < n; i++){
		for(Edge* edge : G.adj[i]){
			if(edge->flow == 1){
				Long u = edge->from;
				Long v = edge->to;
				used[u] = true;
				adj[v-n].push_back(u);
			}
		}
	}
	
	numbers.push_back(0);
	for(Long i = 0; i < n; i++) if(!used[i]) adj[n].push_back(i);
	dfs(n,n,d);
	
	Long sz = ans.size();
	cout << sz-1 << "\n";
	for(Long i = 1; i < sz; i++){
		if(ans[i] == -1){
			cout << "R ";
		}else{
			cout << ans[i] << " \n"[i == sz-1];
		}
	}
	
	return 0;
}
