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;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
vector <int > layer[11];
vector<int > ans;
/*
先分层，然后边分层边用跑dinic 
*/ 
int dep[maxn],pre[maxn],now[maxn],num[maxn];
struct edge{
	int u;
	int v;
	int w;
	int next;
}e[maxn<<3];
int d,n,cnt=0,T,S,head[maxn];
queue<int> q;
void ini(){
	T=2*n+1;
	S=2*n+2;
	memset(head,-1,sizeof(head));
	memset(pre,0,sizeof(pre));
	cnt=-1;
}
void adde(int u,int v){//存双边
	 e[++cnt].v=v;
	 e[cnt].next=head[u];
	 e[cnt].w=1;
	 head[u]=cnt;
	 e[++cnt].v=u;
	 e[cnt].next=head[v];
	 e[cnt].w=0;
	 head[v]=cnt;
}
bool bfs(){
	memset(dep,0,sizeof(dep));
	q.push(S);
	dep[S]=1;
	int u;
	while(q.size()){
		u=q.front();
		q.pop();
		now[u]=head[u];
		int i;
		for(i=head[u];~i;i=e[i].next){
			int v=e[i].v,w=e[i].w;
			if(dep[v]||w==0)continue;
			dep[v]=dep[u]+1;
			q.push(v); 
		}
	}
	return dep[T];
}
int dfs(int u,int flow){
	if(u==T)return flow;
	for(int i=now[u];~i;i=e[i].next){
		now[u]=i;
		int v=e[i].v,w=e[i].w;
		if(!w||dep[v]!=dep[u]+1)continue;//
		int t=dfs(v,min(flow,w));
		if(!t)continue;
		e[i].w-=t;
		e[i^1].w+=t;
		pre[u]=v;
		return t;
	}
	return 0;
}
int main(){
	
	cin>>d>>n;
	string s;
	for(int i=1;i<=n;i++){
		cin>>s;
		for(int j=d-1;j>=0;j--){//1011 13 1101 001 4
		num[i]<<=1;
		if(s[j]=='1'){
			num[i]+=1;}
		}
		layer[__builtin_popcount(num[i])].push_back(i);
	}
	ini();
	
	
	for(int i=1;i<=n;i++){
		adde(S,i);
		adde(i+n,T);
	}
	
	
	for(int i=d;i>0;i--){//从高层开始dinic 贪心 
		for(int j=i+1;j<=d;j++){
			for(int high:layer[j])
			for(int low:layer[i]){
				if((num[low]&num[high])==num[low])
				adde(low,high+n);//low->high 
			}
		}
		while(bfs()){
			dfs(S,INF);
		}
	}
	int k,t1,t2,tp,diff;
	pre[0]=-1;
	for(int i=1;i<=d;i++)
	for(int j:layer[i]){
		if(pre[j]==-1)continue;
		k=j;
		tp=0;
		while(k>=0){
			diff=tp^num[k];
			tp=num[k];
			for(int j_=0;j_<d;j_++){
				if((diff>>j_)&1)ans.push_back(j_);
			}
			t1=k;
			t2=k+n;
			k=pre[k]-n;
			pre[t1]=pre[t2]=-1; 
		}
		ans.push_back(-1);
	}
	int res=ans.size()-1;
	cout<<res<<endl;
	for(int i=0;i<res;i++){
		if(ans[i]==-1)	cout<<"R"<<" ";
		else cout<<ans[i]<<" ";
	}
	return 0;
}