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:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <unordered_map>
#include <complex>
using namespace std;
#define pii pair<int,int>
#define ll long long
typedef complex<double> base;

const double PI = acos(-1);


void precalc()
{

}

void clear()
{
}

const int MAXN = 1 << 10 + 1;
bool is_visited[MAXN];
bool is_visited1[MAXN];
int c[MAXN];
bool is_used[MAXN];
int costs[MAXN];

void dfs1(int v, vector<int> &ar1, vector<int> &ar2)
{
	if (c[v] != -1 && is_used[v])
	{
		ar2.push_back(v);
	}
	for (int i = 0; i < 10; ++i)
	{
		if ((v & (1 << i)) && v != (1 << i))
		{
			int v1 = v - (1 << i);
			if (c[v1] == -1 && is_used[v1])
				ar1.push_back(v1);
			if (!is_visited[v1])
			{
				is_visited[v1] = true;
				dfs1(v1, ar1, ar2);
			}
		}
	}
}

int get_max_cost(int v)
{
	is_visited1[v] = true;
	vector<int> ar1, ar2;
	dfs1(v, ar1, ar2);
	int max_cost = 0;
	for (auto u : ar1)
	{
		max_cost = max(max_cost, costs[u]);
	}
	for (auto u : ar2)
	{
		if (u != v)
			max_cost = max(max_cost, get_max_cost(c[u]));
	}
	return max_cost;
}

bool get_matching(int v, int req_cost)
{
	is_visited1[v] = true;
	vector<int> ar1, ar2;
	dfs1(v, ar1, ar2);
	for (auto u : ar1)
	{
		if (req_cost == costs[u])
		{
			c[u] = v;
			return true;
		}
	}
	for (auto u : ar2)
	{
		if (u != v && get_matching(c[u], req_cost))
		{
			c[u] = v;
			return true;
		}
	}
	return false;
}

void solve()
{
	int n, d1;
	cin >> d1 >> n;
	memset(c, -1, sizeof c);
	for (int i = 0; i < n; ++i)
	{
		string line;
		cin >> line;
		int m = 0;
		for (auto u : line)
		{
			m = m * 2 + u - '0';
		}
		is_used[m] = true;
	}
	for (int i = 0; i < MAXN; ++i)
	{ 
		int cnt = 0;
		for (int j = 0; j < 10; ++j)
		{
			cnt += (bool)((1 << j) & i);
		}
		costs[i] = cnt;
	}
	for (int i = 0; i < MAXN; ++i)
	{
		if (!is_used[i])
			continue;
		memset(is_visited, false, sizeof is_visited);
		memset(is_visited1, false, sizeof is_visited);
		int cost = get_max_cost(i);
		memset(is_visited, false, sizeof is_visited);

		memset(is_visited1, false, sizeof is_visited);
		if (cost > 0)
			get_matching(i, cost);
	}
	memset(is_visited, false, sizeof is_visited);
	vector<string> results;
	for (int i = 0; i < MAXN; ++i)
	{
		string cur_string = "";
		if (!is_used[i] || is_visited[i])
			continue;
		vector<int> d;
		int j = i;
		d.push_back(i);
		while (c[j] != -1)
		{
			j = c[j];
			d.push_back(j);
			is_visited[j] = true;
		}
		int prev_num = 0;
		for (auto num : d)
		{
			for (int c = 0; c < 10; ++c)
			{
				if ((1 << c) & (num ^ prev_num))
					cur_string += ('0' + d1 - c - 1);
			}
			prev_num = num;
		}
		results.push_back(cur_string);
	}
	string answ = "";
	for (auto u : results)
	{
		if (answ.size())
			answ += "R";
		answ += u;
	}
	cout << answ.size() << '\n';
	bool any_char = false;
	for (auto u : answ)
	{
		if (any_char)
		{
			cout << " ";
		}
		any_char = true;
		cout << u;
	}
}
int main()
{
	precalc();
	solve();

	return 0;
}