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>
#define ll long long
#define ford(i,a,n) for(i=a;i<=n;i++)
#define forb(i,n,a) for(i=n;i>=a;i--)
const int MAXN=2e3+10,maxe=1e6+1e5;
using namespace std;
string s[MAXN];
struct ZKW_SPFA{
	#define maxn 5005
	#define maxe (int)(1e6+1e5)
	const int INF=(int)1e9;
	int dis[maxn],vis[maxn],head[maxn],tot;
	int n,Cost=0,Flow=0;
	struct Edge{int v,cap,cost,nxt;}g[maxe<<1];
	void init(int _n){Cost=0;Flow=0;tot=0;memset(head,-1,sizeof(head));n=_n;}
	void add(int u,int v,int cap,int cost)
	{	g[tot]={v,cap,cost,head[u]};	head[u]=tot++;	}
	void addedge(int u,int v,int cap,int cost)
	{	add(u,v,cap,cost);	add(v,u,0,-cost);	}
	bool spfa(int S,int T){
		for(int i=0;i<=n;i++) vis[i]=0,dis[i]=INF;
		deque<int>Q;Q.push_back(T);dis[T]=0;vis[T]=1;
		while(!Q.empty())
		{
			int u=Q.front();Q.pop_front();
			for(int i=head[u],v;~i;i=g[i].nxt)
				if(g[i^1].cap&&dis[v=g[i].v]>dis[u]+g[i^1].cost)
				{
					dis[v]=dis[u]+g[i^1].cost;
					if(!vis[v])
					{
						vis[v]=1;
						if(!Q.empty()&&dis[v]<dis[Q.front()]) Q.push_front(v);
						else Q.push_back(v);
						//SLFÓÅ»¯
					}
				} vis[u]=0;
		} return dis[S]<INF;
	}
	int dfs(int S,int T,int flow)
	{
		if(S==T) {	vis[T]=1;	return flow;	}
		int used=0,res;	vis[S]=1;
		for(int i=head[S],v;~i;i=g[i].nxt)
			if(!vis[v=g[i].v]&&g[i].cap&&dis[S]-g[i].cost==dis[v])
			{
				res=dfs(v,T,min(g[i].cap,flow-used));
				if(res) Cost+=res*g[i].cost,g[i].cap-=res,g[i^1].cap+=res,used+=res;
				if(used==flow)break;
			}
		return used;
	}
	void solve(int S,int T)
	{
		while(spfa(S,T))
		{
			vis[T]=1;
			while(vis[T]) memset(vis,0,sizeof vis),Flow+=dfs(S,T,INF);
		}
	}
	int nn;
	void sout(int aa,int bb)
	{
	//	cout<<"\n"<<aa<<" "<<bb<<endl;// return;
		if(aa==0) 
		{
			for(int i=0;i<nn;i++)
				if(s[bb][i]=='1') cout<<i<<" ";
		}
		else
			for(int i=0;i<nn;i++)
				if(s[bb][i]!=s[aa][i]) cout<<i<<" ";
	}
	void dfout(int p,int T,int ctm,int lst)
	{
		if(p==T) return;
		sout(lst,p);
		for(int i=head[p+ctm];~i;i=g[i].nxt)
		{
			if((i&1)==0&&g[i].cap==0)
			{
				dfout(g[i].v,T,ctm,p);
				return;
			}
		}
	}
	void outans(int S,int T,int ctm,int nnn)
	{
		int fl=0; nn=nnn;
		for(int i=head[S];~i;i=g[i].nxt)
		{
		//	cout<<g[i].v<<"***"<<endl;
			if((i&1)==0&&g[i].v<=ctm&&g[i].cap==0)
			{
				if(fl) cout<<"R ";
				else fl=1;
				dfout(g[i].v,T,ctm,0);
			}
		}
	}
}zkw;
int n,m;
int get(string a,string b)
{
	int i=0;
	int sum=0;
	ford(i,0,n-1)
	{
		if(a[i]>b[i]) return -1;
		if(a[i]!=b[i])
		sum++;
	}
	return sum;
}
int cal(int p)
{
	int len=s[p].length(),kk=0;
	for(int i=0;i<len;i++)
	{
		if(s[p][i]=='1') kk++;
	}
	return kk;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int i,j,k,t,st,ed;
	cin>>n>>m;
	zkw.init(m*2+5);
	st=m*2+1,ed=m*2+2;
//	cout<<"***"<<endl; 
	ford(i,1,m) cin>>s[i];
	ford(i,1,m)
	ford(j,1,m)
	{
		if(i==j) continue;
		k=get(s[i],s[j]);
		if(k!=-1)
		{
			zkw.addedge(i+m,j,1,k);
		}
	}
	for(i=1;i<=m;i++)
	{
		zkw.addedge(st,i,1,cal(i)+1);
		zkw.addedge(st,i+m,1,0);
		zkw.addedge(i,ed,1,0);
	}
	zkw.solve(st,ed);
	cout<<zkw.Cost-1<<endl;
	zkw.outans(st,ed,m,n); cout<<endl;
}