// Blackpink in your area
// corner cases // int vs ll // clear structures // statement // doublesz // line order // 0-1-indexed
#include <bits/stdc++.h>
#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

typedef ll tf;
typedef ll tc;
const tf INFFLOW = 1e9;
const tc INFCOST = 1e9;
const int MAXN = 1024 * 2 + 20;

int to_mask(string s){
	int ans = 0;
	for(int i = 0; i < sz(s); ++i){
		if(s[i] == '1'){
			ans |= (1 << i);
		}
	}
	return ans;
}

const int inf = 1e9;
int d, n;
int mark[MAXN];
int get_mask[MAXN];
int in_node[MAXN], out_node[MAXN];

struct MCF{
	int n;
	vector<tc> prio, pot;
	vector<tf> curflow;
	vector<int> prevedge, prevnode;
	priority_queue<pair<tc,int>, vector<pair<tc,int>>, greater<pair<tc,int>>> q;
	struct edge{ int to, rev; tf f, cap; tc cost; };
	vector< vector<edge> > g;
	MCF(int n) : n(n), prio(n), curflow(n), prevedge(n), prevnode(n), pot(n), g(n){}
	void add_edge(int s, int t, tf cap, tc cost){
		// cout << "Adding edge from " << s << " to " << t << " cap = " << cap << " cost = " << cost << endl;
		g[s].pb((edge){t, sz(g[t]), 0, cap, cost});
		g[t].pb((edge){s, sz(g[s])-1, 0, 0, -cost});
	}
	pair<tf,tc> get_flow(int s, int t){
		tf flow = 0;
		tc flowcost = 0;
		while(1){
			q.push({0,s});
			fill(prio.begin(), prio.end(), INFCOST);
			prio[s] = 0; curflow[s] = INFFLOW;
			while(!q.empty()){
				auto cur = q.top();
				tc d = cur.first;
				int u = cur.second;
				q.pop();
				if(d != prio[u]) continue;
				for(int i = 0; i < sz(g[u]); ++i){
					edge &e = g[u][i];
					int v = e.to;
					if(e.cap <= e.f) continue;
					tc nprio = prio[u] + e.cost + pot[u] - pot[v];
					if(prio[v] > nprio){
						prio[v] = nprio;
						q.push({nprio, v});
						prevnode[v] = u; prevedge[v] = i;
						curflow[v] = min(curflow[u], e.cap - e.f);
					}
				}
			}
			if(prio[t] == INFCOST) break;
			REP(i,n) pot[i] += prio[i];
			tf df = min(curflow[t], INFFLOW - flow);
			flow += df;
			for(int v = t; v != s; v = prevnode[v]){
				edge &e = g[prevnode[v]][prevedge[v]];
				e.f += df; g[v][e.rev].f -= df;
				flowcost += df * e.cost;
			}
		}
		return {flow, flowcost};
	}

	vector<int> solve(int s, int t, int flow){
		vector<int> ans;
		t--; // ssink -> sink
		while(flow--){
			int now = s;
			while(1){
				// cross self
				int v = -1;
				int cur_msk = get_mask[now];
				for(auto &e : g[now]){
					if(e.f > 0){
						e.f--;
						v = e.to;
						break;
					}
				}
				assert(v >= 0);
				now = v;
				v = -1;
				// cross to another mask
				for(auto &e : g[now]){
					if(e.f > 0){
						e.f--;
						v = e.to;
						break;
					}
				}
				assert(v >= 0);
				if(v == t) break;
				now = v;
				int bit = -1;
				int new_msk = get_mask[now];
				for(int i = 0; i < d; ++i){
					if( (cur_msk & (1 << i)) == 0 && (new_msk & (1 << i)) > 0 ){
						bit = i;
						break;
					}
				}
				assert(bit >= 0);
				ans.pb(bit);
			}
			ans.pb(-1);
		}
		ans.pop_back();
		return ans;
	}

};

int src = 0, sink = MAXN - 5;
int ssink = sink + 1;
vector<int> ans;
vector< array<int,4> > edges;

int network_cost(int lim, int last = 0){
	MCF network(MAXN);
	for(auto ar : edges){
		network.add_edge(ar[0], ar[1], ar[2], ar[3]);
	}
	network.add_edge(sink, ssink, lim, 0);
	auto f = network.get_flow(src, ssink);
	if(last){
		ans = network.solve(src, ssink, f.fst);
	}
	return f.snd;
}

int main(){

	fastio;
	cin >> d >> n;
	
	MCF network(MAXN);
	int gid = 0;
	for(int m = 0; m < (1 << d); ++m){
		in_node[m] = gid++;
		out_node[m] = gid++;
		get_mask[in_node[m]] = m;
		get_mask[out_node[m]] = m;
		edges.pb({in_node[m], out_node[m], inf, 0});
		if(m > 0){
			edges.pb({out_node[m], sink, inf, 0});
		}
	}

	for(int m = 0; m < (1 << d); ++m){
		for(int j = 0; j < d; ++j){
			if(m & (1 << j)) continue;
			int nm = m | (1 << j);
			edges.pb({out_node[m], in_node[nm], inf, 1});
		}
	}

	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		int msk = to_mask(s);
		edges.pb({in_node[msk], out_node[msk], 1, int(-1e5)});
	}

	int lo = 0, hi = 254;
	while(hi - lo > 1){
		int mid = (lo + hi) / 2;
		if(network_cost(mid) >= network_cost(mid+1)) lo = mid;
		else hi = mid;
	}

	network_cost(lo+1, 1);

	cout << sz(ans) << endl;
	for(int x : ans){
		if(x == -1) cout << "R ";
		else cout << x << " ";
	}
	cout << endl;

	return 0;
}
