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;

//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back
#define fi first
#define se second
#define ll long long
#define tp top()
#define fr front()
#define vi vector<int>
#define sz size()
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define mem(a,  b) memset(a,  (b),  sizeof(a))
#define clr(a) memset(a,  0,  sizeof(a))
#define sqr(x) ( (x) * (x) )
#define all(v) v.begin(),  v.end()

typedef pair<int, int> pii;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;



void base(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

#define N 5020

vector<int> adj[N]; // harus dibikin ke bipartide 1 arah
int match[N], vis[N]; 
bool bpm(int cur) { 
  	for (int to : adj[cur]) { 
    	if (vis[to]) continue;
    	vis[to] = true;          
    	if (match[to] < 0 || bpm(match[to])) { 
      		match[to] = cur; return true; 
    	}         
  	} 
 	return false; 
} 

int MCBM(int n){ // n=jumlah node
    mem(match,-1);
    int result = 0;  
    for (int i = 0; i < n; i++) { 
        clr(vis);
        if (bpm(i)) result++; 
    } 
    return result; 
} 

ll mult[20];
string s[N];
ll a[N],c[N];

vector<ll> ans;
bool visited[N];

void backt(int x, int n){
	visited[x] = 1;
	int y = match[x+n];
	int z;
	if (y == -1){		
		z = a[x];
	} else {
		backt(y, n);
		z = ((a[x] & a[y]) ^ (a[x]));
	}
	while(z>0){
		int aa = log2(z&(-z));
		ans.pb(aa);
		z &= (z-1);
	}
}

bool compare(pii a, pii b){
	return a.fi > b.fi;
}


void solve(){
	ans.clear();
	
	int d,n; cin>>d>>n;
	rep(i,0,n) cin>>s[i];
	mult[0] = 1;
	rep(i,1,d+1) mult[i] = mult[i-1]*2;		
	vector<pii> vec;
	rep(i,0,n){		
		rep(j,0,d){
			if (s[i][j]=='1') {
				a[i]+=mult[j];			
				c[i]++;
			}
		}
		vec.pb({c[i],a[i]});
	}
	sort(all(vec), compare);
	rep(i,0,n){
		c[i] = vec[i].fi;
		a[i] = vec[i].se;
	}
	rep(i,0,n){
		rep(j,i+1,n){
			if (c[i]==c[j]) continue;
			int xi = i, yi = j;
			if (c[xi] < c[yi]) swap(xi,yi);
			if ((a[xi] | a[yi]) != a[xi]) continue;
			adj[yi].pb(xi+n);
		}
	}
	MCBM(n);
	
	for(int i=d; i>=1;i--){
		rep(j,0,n){
			if (c[j] != i) continue;
			if (visited[j]) continue;
			backt(j,n);
			ans.pb(-999);
		}
	}
	ans.pop_back();
	cout<<ans.sz<<"\n";
	for(int i = 0; i < ans.sz; i++){
		if (ans[i] == -999) cout<<"R";
		else cout<<ans[i];
		if (i+1==ans.sz) cout<<"\n";
		else cout<<" ";
	}
	
}

int main()
{
	base();
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}