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 pc putchar
#define gc() getchar()
#define pb emplace_back
using namespace std;

inline int read()
{
	int now=0,f=1; char c=gc();
	for(;!isdigit(c); c=='-'&&(f=-1), c=gc());
	for(; isdigit(c); now=now*10+c-48, c=gc());
	return now*f;
}

int d,n,x;
const int maxn = 2000;
const int INF = 100000;
const int N = 2000; 
vector<int> G[1333];
vector<int> state;
int idx[4040];

int in0[maxn];

#define cb __builtin_popcount


struct KM{
	int nx,ny;//两边的点数
	int g[N][N];//二分图描述
	int linker[N],lx[N],ly[N];//y中各点匹配状态，x,y中的点标号
	int tok[N];
	int slack[N];
	bool visx[N],visy[N];
	void init(int x , int y){
		nx = x;
		ny = y;
	}
	 
	bool DFS(int x)
	{
	    visx[x] = true;
	    for(int y = 1; y <= ny; y++)
	    {
	        if(visy[y]) continue;
	        int tmp = lx[x] + ly[y] - g[x][y];
	        if(tmp == 0)
	        {
	            visy[y] = true;
	            if(linker[y] == -1 || DFS(linker[y]))
	            {
	                linker[y] = x;
	                return true;
	            }
	        }
	        else if(slack[y] > tmp)
	            slack[y] = tmp;
	    }
	    return false;
	}
	int run()
	{
	    memset(linker,-1,sizeof(linker));
	    memset(ly,0,sizeof(ly));
	    for(int i = 1;i <= nx;i++)
	    {
	        lx[i] = -INF;
	        for(int j = 1;j <= ny;j++)
	            if(g[i][j] > lx[i])
	                lx[i] = g[i][j];
	    }
	    for(int x = 1;x <= nx;x++)
	    {
	        for(int i = 1;i <= ny;i++)
	            slack[i] = INF;
	        while(true)
	        {
	            memset(visx,false,sizeof(visx));
	            memset(visy,false,sizeof(visy));
	            if(DFS(x))break;
	            int d = INF;
	            for(int i = 1;i <= ny;i++)
	                if(!visy[i] && d > slack[i])
	                    d = slack[i];
	            for(int i = 1;i <= nx;i++)
	                if(visx[i])
	                    lx[i] -= d;
	            for(int i = 1;i <= ny;i++)
	            {
	                if(visy[i])ly[i] += d;
	                else slack[i] -= d;
	            }
	        }
	    }
	    int res = 0;
	    for(int i = 1;i <= ny;i++)
	        if(linker[i] != -1)
	            res += g[linker[i]][i];
	            
	    for (int i = 1; i <= ny ; ++i){
	    	if(g[linker[i]][i])
	    		tok[linker[i]] = i;
		}
	    return res;
	}
}solver;


void genGraph(){
	int sz = state.size();
	for (int i = 1 ; i <= n ; ++i){
		for (int j = 1 ; j <= n ; ++j){
			if(i == j) continue;
			if( (state[i] | state[j]) == state[j] ){
				G[i].push_back(j);
			//	in0[j]++;
			//	cout << i << ' ' << j << endl; 
				solver.g[i][j] = 10000-cb( state[i] ^ state[j]);
			}
		}
	}	
}

vector<string> ans;
void trans(int x , int y){
	for (int i = 0 ; i < d ; ++i){
		int num = 1 << i;
		if( (num & y) && !(num & x)){
			ans.push_back(to_string(d-i-1));
		}
	}	
}
bool vis[1333];
bool inq[1333];
queue<int> q;

int tot = 0;
int stk[maxn + 10];
int to[maxn+10];


bool findPath(int from ,int to,  int step = 1){	
	stk[step] = from;
	if(from == to){
		tot = step;
		return true;
	}
	for (int v : G[from]){
		if( findPath(v,to,step+1) ) 
			return true;
	}
	return false;
}

void free(int x){
	if(--in0[to[x]] == 0 && !vis[x])
		q.push(to[x]);
	
}
void deal(int x){
	vis[x] = 1;
	vector<int> vec;
	
	while(int nxt = solver.tok[x]){
		
		findPath(x,nxt);
		vis[nxt] = 1;
		vec.push_back(x);
		vis[x] = vis[nxt] = 1;
		
		for (int i = 1 ; i < tot; ++i){
			trans(state[ stk[i] ], state[ stk[i+1] ]);
		}
		x = nxt;
	}
	for (int b : vec) free(b);
}



int main()
{
	bitset<12> bt;
	scanf("%d%d",&d,&n);
	solver.init(n,n);
	state.push_back(-1);
	for (int i = 1 ; i <= n ; ++i){
		cin >> bt;
		x = bt.to_ulong();
		state.push_back(x);
		idx[x] = i;
	}
	genGraph();
	
	solver.run();
	for (int i = 1 ; i <= n ; ++i){
		to[i] = solver.tok[i];
		if(to[i]){
			in0[to[i]]++;
		}
	}
	for (int i = 1;  i<= n ; ++i){
		
		if(in0[i] == 0)
		{
			q.push(i);
		}
	}
	
	bool start = 0;
	while(!q.empty()){
		int x = q.front();
	//	printf("?%d?\n",x);
		q.pop();
		
		if(start == 0){
			start = 1;
		} else {
			ans.push_back("R");
		}
	
		if(state[x] != 0) trans(0,state[x]); 
		deal(x);
	}
	
	cout << ans.size()<< endl; 
	for (const string& s : ans){
		cout << s <<' ';
	}
	cout << endl;

	return 0;
}