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 <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxk = 10, mxn = 1 << mxk;
int n, k;
int a[mxn], f[mxn], vis[mxn];
vector<int> v;
vector<int> g[mxn];

bool dfs(int c){
	vis[c] = 1;
	for(int i : g[c]){
		if(!f[i] || (!vis[f[i]] && dfs(f[i]))){
			f[i] = c;
			return 1;
		}
	}
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k >> n;
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < k; j++){
		char c;
		cin >> c;
		a[i] |= (c & 1) << j;
	}
	
	sort(a, a + n, [&](int x, int y){
		return __builtin_popcount(x) > __builtin_popcount(y);	
	});
	
	for(int i = 0; i < n; i++)
	for(int j = 0; j < i; j++){
		if((a[i] & a[j]) == a[i]) g[i].push_back(j);
	}
	
	for(int i = 0; i < n; i++){
		memset(vis, 0, sizeof(vis));
		dfs(i);
	}
	
	memset(vis, 0, sizeof(vis));
	for(int i = 0; i < n; i++) if(!vis[i]){
		int x, y;
		v.push_back(-1);
		for(x = f[i], y = a[i]; x; y = a[x], x = f[x]){
			vis[x] = 1;
			for(int j = 0; j < k; j++){
				if(((a[x] ^ y) >> j) & 1) v.push_back(j);
			}
		}
		for(int j = 0; j < k; j++) if((y >> j) & 1) v.push_back(j);
	}
	
	reverse(v.begin(), v.end());
	
	cout << (v.size() - 1) << endl;
	cout << v[0];
	for(int i = 1; i < v.size() - 1; i++){
		cout << " ";
		if(!~v[i]) cout << "R";
		else cout << v[i];
	}
	cout << endl;
	
	return 0;
}