Problem: You are standing in front of the room with great treasures. The only thing stopping you is the door with a push-button combination lock. This lock has d buttons with digits from 0 to d - 1. Whenever you press a button, it stays pushed down. You can not pop back up just one button, but there is a "RESET" button — pressing it pops up all other buttons. Initially, no buttons are pushed down.

The door instantly opens when some specific set of digits is pushed down. Sadly, you don't know the password for it. Having read the documentation for this specific lock, you found out that there are n possible passwords for this particular lock. 

Find the shortest sequence of button presses, such that all possible passwords appear at least once during its execution. Any shortest correct sequence of button presses will be accepted.

Input

The first line contains two integers d and n (1 ≤ d ≤ 10; 1 ≤ n ≤ 2^d - 1). Next n lines describe possible passwords. Each line contains a string s_i of d zeros and ones: for all j from 1 to d the j-th character is 1 iff the button with the digit j - 1 must be pushed down.

All strings s_i are different, and each string contains at least one 1.

Output

On the first line, print the number k — the minimum number of button presses. On the second line, print k tokens, describing the sequence. Whenever you press a button with a digit, print that digit. Whenever you press "RESET", print "R".

Examples

Input


2 2
10
11


Output


2
0 1 


Input


3 4
001
111
101
011


Output


6
2 0 R 1 2 0 

Note

In the second example, the sequence 1 2 R 2 0 1 is also possible.

Solution (in CPP):

Solution:
#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;
}