#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LC k<<1
#define RC k<<1|1

typedef long long LL;
const int N=110000;
const int M=4100000;
const LL mod=1e9+7;
int e[M],f[M],w[M],pre[M],last[N];
int d[N],dd[N],pp[N],now[N];
int n,m,k;
int num=1,st,ed,maxflow,flag;
queue<int> q;
void insert(int x,int y,int z,int c)
{
	e[++num]=y,f[num]=z,w[num]=c,pre[num]=last[x],last[x]=num;
	e[++num]=x,f[num]=0,w[num]=-c,pre[num]=last[y],last[y]=num;
}
bool spfa()
{	
	for (int i=st;i<=ed;i++)
		d[i]=dd[i]=1e9,pp[i]=0;
	q.push(st);
	d[st]=dd[st]=0;pp[st]=1;
	while (!q.empty())
	{
		int x=q.front();
		for (int i=last[x];i;i=pre[i])
		{
			if (!f[i]) continue;
			int y=e[i];
			if (d[y]>d[x]+w[i]||d[y]==d[x]+w[i]&&dd[y]>dd[x]+1)
			{
				d[y]=d[x]+w[i];
				dd[y]=dd[x]+1;
				if (!pp[y]) pp[y]=1,q.push(y);
			}
		}
		pp[x]=0;
		q.pop();
	}
	if (d[ed]>=0) return false;
	return true;
}
int dfs(int x,int incf)
{
    if(x==ed)return incf;
    int flow=0,ww;
    for (int i=now[x];i;i=pre[i])
        if(f[i]&&dd[e[i]]==dd[x]+1&&d[e[i]]==d[x]+w[i])
        {
			ww=dfs(e[i],min(incf-flow,f[i]));
            f[i]-=ww,f[i^1]+=ww;
            flow+=ww;
            if (f[i]) now[x]=i;
			if(flow==incf) return incf;
        }
    if(!flow) dd[x]=-1;
    return flow;
}
void dinic()
{
	while(spfa()) 
	{
		for (int i=st;i<=ed;i++)
			now[i]=last[i];
		maxflow+=dfs(st,1e9);
	}
}
int a[N];
char s[N];
int cnt;
vector<int> ans;
int main()
{
	scanf("%d %d",&k,&n);
	st=0,ed=2*n+1;
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s);
		int x=0;
		for (int j=0;j<k;j++)
			x+=(s[j]-'0')<<j;
		a[i]=x;
		insert(st,2*i-1,1,__builtin_popcount(a[i])+1);
		insert(2*i,ed,1,0);
		insert(2*i-1,2*i,1,-100000);
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i!=j&&(a[i]&a[j])==a[i])
				insert(2*i,2*j-1,1,__builtin_popcount(a[j])-__builtin_popcount(a[i]));
	dinic();
	for (int i=last[st];i;i=pre[i])
		if (f[i]==0)
		{
			if (cnt) ans.pb(-1);
			int now=0,pos=e[i]+1,v=a[(e[i]+1)/2];
			for (int j=0;j<k;j++)
				if ((v>>j)&1) ans.pb(j);
			while (true)
			{
				int npos;
				for (int j=last[pos];j;j=pre[j])
					if (f[j]==0)
					{
						npos=e[j];
						break;
					}
				if (npos==ed) break;
				npos++;
				pos=npos;
				int nv=a[npos/2];
				for (int j=0;j<k;j++)
					if (((v>>j)&1)==0&&((nv>>j)&1)==1) ans.pb(j);
				v=nv;
			}
			cnt++;
		}
	printf("%d\n",ans.size());
	for (int i=0;i<ans.size();i++)
	{
		if (ans[i]==-1) printf("%c",'R');
		else printf("%d",ans[i]);
		if (i!=ans.size()-1) printf(" ");
		else printf("\n");
	}
	return 0;
}