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;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

struct tedge
{
	int to, f, maxf, cost, o;
};

const int maxn = (1 << 12) + 5;
const int inf = 1e5;

vector<tedge> gr[maxn];
int d[maxn];
bool inq[maxn];
queue<int> q;
char s[20];
int n, m;
int from[maxn];
vector<char> answer;

void addedge(int a, int b, int maxf, int cost)
{
	int sza = gr[a].size();
	int szb = gr[b].size();
	gr[a].pb({b, 0, maxf, cost, szb});
	gr[b].pb({a, 0, 0, -cost, sza});
}

void maxflow(int nn)
{
	while (true)
	{
		for (int i = 0; i < nn; i++)
		{
			d[i] = inf;
			inq[i] = false;
		}
		d[0] = 0;
		inq[0] = true;
		q.push(0);
		while (!q.empty())
		{
			int cur = q.front();
			q.pop();
			//cout << cur << ' ' << d[cur] << endl;
			inq[cur] = false;
			for (auto e : gr[cur]) if (e.f < e.maxf && d[e.to] > d[cur] + e.cost)
			{
				//cout << "check " << e.to << ' ' << e.maxf << endl;
				d[e.to] = d[cur] + e.cost;
				from[e.to] = e.o;
				if (!inq[e.to])
				{
					q.push(e.to);
					inq[e.to] = true;
				}
			}
		}
		//cout << "flow " << d[nn - 1] << endl;
		if (d[nn - 1] >= 0) break;
		int cur = nn - 1;
		while (cur != 0)
		{
			int nxte = from[cur];
			int nxtv = gr[cur][nxte].to;
			gr[cur][nxte].f--;
			nxte = gr[cur][nxte].o;
			cur = nxtv;
			gr[cur][nxte].f++;
		}
	}
}

int main()
{
	scanf("%d%d", &m, &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", s);
		int x = 0;
		for (int i = 0; i < m; i++) if (s[i] == '1') x += (1 << i);
		addedge(2 * x, 2 * x + 1, 1, -inf);
	}
	int nn = 2 * (1 << m) + 1;
	for (int mask = 0; mask < (1 << m); mask++)
	{
		addedge(2 * mask, 2 * mask + 1, inf, 0);
		if (mask != 0) addedge(2 * mask + 1, nn - 1, inf, 1);
		for (int i = 0; i < m; i++) if (!(mask & (1 << i)))
		{
			addedge(2 * mask + 1, 2 * (mask | (1 << i)), inf, 1);
		}
	}
	
	maxflow(nn);
	while (true)
	{
		int cur = 0;
		bool bad = false;
		while (cur != nn - 1)
		{
			bool found = false;
			for (auto &e : gr[cur]) if (e.f > 0)
			{
				found = true;
				if ((cur & 1) == 1 && (e.to & 1) == 0 && e.to != nn - 1)
				{
					int a = cur >> 1;
					int b = e.to >> 1;
					answer.pb('0' + __builtin_ctz(a ^ b));
				}
				if (e.to == nn - 1) answer.pb('R');
				e.f--;
				cur = e.to;
				break;
			}
			if (!found)
			{
				bad = true;
				break;
			}
		}
		if (bad) break;
	}
	answer.pop_back();
	printf("%d\n", (int)answer.size());
	for (auto c : answer) printf("%c ", c);
	printf("\n");
    return 0;
}