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
const int N=10005,inf=1e7;
int n,m,head[N],cnt=1,T=9999,S=9998,iter[N],dis[N],ex[N],et[N];
bool vis[N];
struct edge{
	int to,nxt,cap,cost;
}e[N*8];
inline int addedge(int u,int v,int cap,int cost){
	e[++cnt]=(edge){v,head[u],cap,cost},head[u]=cnt;
	e[++cnt]=(edge){u,head[v],0,-cost},head[v]=cnt;
	return cnt-1;
}
int dfs(int u,int f){
	if(u==T||!f)return f;
	vis[u]=1;
	int res=0;
	for(int&i=iter[u];i;i=e[i].nxt)
		if(e[i].cap&&dis[e[i].to]==dis[u]+e[i].cost&&!vis[e[i].to]){
			int d=dfs(e[i].to,min(f,e[i].cap));
			if(d){
				res+=d,f-=d;
				e[i].cap-=d,e[i^1].cap+=d;
				if(!f)break;
			}
		}
	vis[u]=0;
	return res;
}
bool MCMF(){
	memset(dis,0x3f,sizeof dis);
	dis[S]=0;
	queue<int>q;
	for(q.push(S);q.size();){
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].cap&&dis[e[i].to]>dis[u]+e[i].cost){
				dis[e[i].to]=dis[u]+e[i].cost;
				if(!vis[e[i].to]){
					vis[e[i].to]=1;
					q.push(e[i].to);
				}
			}
	}
	if(dis[T]>inf)return 0;
	memcpy(iter,head,sizeof iter);
	while(dfs(S,inf));
	return 1;
}
vector<int>G[N];
int sta[2000000],top;
void dfs(int u){
	vis[u]=1;
	for(int i=iter[u];i<(int)G[u].size();i=iter[u]){
		iter[u]=i+1;
		int v=G[u][i];
		dfs(v);
	}
	sta[++top]=u;
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	addedge(S,0,1,0);
	addedge(S,0,inf,1);
	for(int i=0;i<1<<n;++i)
		for(int j=0;j<n;++j)
			if(!(i>>j&1))
				addedge(i,i|1<<j,inf,1);
	for(int ss=0;m--;ss=0){
		char s[30];
		cin>>s;
		for(int i=0;i<n;++i)
			ss|=(int)(s[i]-'0')<<i;
		ex[ss]=addedge(ss,T,1,0);
		et[ss]=addedge(S,ss+3000,1,0);
		for(int j=0;j<n;++j)
			if(!(ss>>j&1))
				addedge(ss+3000,ss|1<<j,1,1);
	}
	while(MCMF());
	for(int i=0;i<1<<n;++i)if(ex[i]){
		if(e[et[i]].cap<1)
			G[i].emplace_back(i+3000);
		else G[i].emplace_back(0);
	}
	for(int u=0;u<1<<n;++u){
		for(int i=head[u];i;i=e[i].nxt)
			if(e[i].to>u&&e[i].to<(1<<n))
				for(int t=inf;t>e[i].cap;--t)
					G[u].emplace_back(e[i].to);
		for(int i=head[u+3000];i;i=e[i].nxt)
			if(e[i].to>u&&e[i].to<(1<<n))
				for(int t=1;t>e[i].cap;--t)
					G[u+3000].emplace_back(e[i].to);
	}
	memset(iter,0,sizeof iter);
	dfs(0);
	reverse(sta+1,sta+top+1);
	vector<char>vc;
	for(int i=1;i<top;++i){
		if(sta[i+1]==sta[i]+3000)
			continue;
		else if(sta[i+1]==0)
			vc.emplace_back('R');
		else{
			int x=sta[i]>3000?sta[i]-3000:sta[i],y=sta[i+1];
			vc.emplace_back('0'+__builtin_ctz(y-x));
		}
	}
	vc.pop_back();
	cout<<vc.size()<<'\n';
	for(char c:vc)
		cout<<c<<' ';
	return 0;
}