#include<bits/stdc++.h>
using namespace std;
#define see(x) cerr << (#x) << "=" << (x) << endl
typedef long long ll;
const int N=100001;
const int maxn = 1 << 12 | 7;
const int inf=0x3f3f3f3f;
ll maxflow,mincost;
int last[N],pre[N],dis[N],flow[N],d[N];
bool vis[N];
struct Edge{
    int next,to,flow,prem,dis;
}edge[N<<1];
int pos=1,head[N];
void init()
{
    pos=1;memset(head,0,sizeof head);mincost=maxflow=0;
}
queue <int> q;
inline void add(int from,int to,int flow,int dis)//flow流量 dis费用
{
//	cout << "edge: " << from << ' ' << to << endl;
    edge[++pos].next=head[from];edge[pos].flow=flow;edge[pos].dis=dis;edge[pos].to=to;head[from]=pos;edge[pos].prem=flow;
    edge[++pos].next=head[to];edge[pos].flow=0;edge[pos].dis=-dis;edge[pos].to=from;head[to]=pos;edge[pos].prem=0;
}
void ins(int x,int y,int down,int up,int cost)
{
    add(x,y,up-down,cost);
    d[x]-=down;
    d[y]+=down;
}
bool spfa(int s,int t)
{
    memset(dis,0x3f,sizeof dis);
    memset(flow,0x3f,sizeof flow);
    memset(vis,0,sizeof vis);
    while (!q.empty()) q.pop();
    dis[s]=0; pre[t]=-1; q.push(s); vis[s]=1;
    int tot=0;
    while (!q.empty())
    {
        int now=q.front(); q.pop(); vis[now]=0;
        for (int i=head[now]; i; i=edge[i].next)
        {
            int to=edge[i].to;
            if  (edge[i].flow>0 && dis[to]>dis[now]+edge[i].dis)
            {
                dis[to]=edge[i].dis+dis[now];
                flow[to]=min(edge[i].flow,flow[now]);
                last[to]=i;
                pre[to]=now;
                if (!vis[to])
                {
                    q.push(to); vis[to]=1;
                }
            }
        }
    }
    return pre[t]!=-1;
}
inline void MCMF(int s,int t)
{
    while (spfa(s,t))
    {
        int now=t;
        maxflow+=flow[t];
        mincost+=flow[t]*dis[t];
        while (now!=s)
        {
            edge[last[now]].flow-=flow[t];//dis . flow
            edge[last[now]^1].flow+=flow[t];
            now=pre[now];
        }
    }
}
int n,m,k,s,t,ss,a,b,S,T;

int fw[1 << 10 | 7][1 << 10 | 7];

int choose[maxn];

string ans;

bool dfs(int u) {
	if (u == 1) ans.push_back('R');
	int x = u - 1;
	for (int i = 0; i < k; ++i) if (!(x >> i & 1)) {
		int y = x | 1 << i;
		if (fw[x + 1][y + 1]) {
			fw[x + 1][y + 1]--;
			ans.push_back(char('0' + i));
			return dfs(y + 1);
		}
	}
	return u != 1;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int nn;
    cin >> k >> nn;
    n = 1 << k;
    s = 2 * n + 1;
	t = s + 1;
	S = t + 1;
	T = S + 1;

	for (int i = 1; i <= nn; ++i) {
		string s; cin >> s;
		int x = 0;
		for (int j = s.size() - 1; j >= 0; --j) x = x * 2 + s[j] - '0';
//		for (char c: s) x = x * 2 + c - '0';
		x += 1;
		choose[x] = 1;
//		see(x);
	}
	for (int i = 1; i <= n; ++i) {
		int x = i;
		if (choose[x]) {
			ins(x, x + n, 1, inf, 0);
			ins(x + n, t, 0, inf, 1);
		}
		else ins(x, x + n, 0, inf, 0);
	}
	
	for (int i = 1; i <= n; ++i) {
		int x = i - 1;
		for (int j = 0; j < k; ++j) if (!(x >> j & 1)) {
			int y = x | 1 << j;
			ins(x + 1 + n, y + 1, 0, inf, 1);
		}
	}
	
	ins(s, 1, 0, inf, 0);

    //正常建图  s为源点 t为汇点    sum为所有得下界*费用和
 
    ins(t,s,0,inf,0);
    for(int i=1;i<=t;i++)
	    if(d[i]>0)add(S,i,d[i],0);
	    else if(d[i]<0)add(i,T,-d[i],0);
    MCMF(S,T);
    cout << mincost - 1 << endl;
	
	for (int u = n + 1; u < s; ++u) {
		for (int i = head[u]; i; i = edge[i].next) {
			int v = edge[i].to;
			if (v > n) continue;
			if (i % 2) continue;
			fw[u - n][v] = edge[i].prem - edge[i].flow;
		}
	}
//	for (int i = 1; i <= n; ++i) {
//		for (int j = 1; j <= n; ++j) cout << fw[i][j] << " \n"[j == n];
//	}
	while (dfs(1));
	ans.pop_back();
	for (int i = 1; i < ans.size(); ++i) cout << ans[i] << " \n"[i == ans.size() - 1];
}
//答案即为（求出的费用+原图中边的下界*边的费用）！！！！！！！！！！！！！
