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;
#define see(x) cerr << (#x) << "=" << (x) << endl
typedef long long ll;
const int N=100001;
const int maxn = 1 << 12 | 7;
const int inf=0x3f3f3f3f;
ll maxflow,mincost;
int last[N],pre[N],dis[N],flow[N],d[N];
bool vis[N];
struct Edge{
    int next,to,flow,prem,dis;
}edge[N<<1];
int pos=1,head[N];
void init()
{
    pos=1;memset(head,0,sizeof head);mincost=maxflow=0;
}
queue <int> q;
inline void add(int from,int to,int flow,int dis)//flow流量 dis费用
{
//	cout << "edge: " << from << ' ' << to << endl;
    edge[++pos].next=head[from];edge[pos].flow=flow;edge[pos].dis=dis;edge[pos].to=to;head[from]=pos;edge[pos].prem=flow;
    edge[++pos].next=head[to];edge[pos].flow=0;edge[pos].dis=-dis;edge[pos].to=from;head[to]=pos;edge[pos].prem=0;
}
void ins(int x,int y,int down,int up,int cost)
{
    add(x,y,up-down,cost);
    d[x]-=down;
    d[y]+=down;
}
bool spfa(int s,int t)
{
    memset(dis,0x3f,sizeof dis);
    memset(flow,0x3f,sizeof flow);
    memset(vis,0,sizeof vis);
    while (!q.empty()) q.pop();
    dis[s]=0; pre[t]=-1; q.push(s); vis[s]=1;
    int tot=0;
    while (!q.empty())
    {
        int now=q.front(); q.pop(); vis[now]=0;
        for (int i=head[now]; i; i=edge[i].next)
        {
            int to=edge[i].to;
            if  (edge[i].flow>0 && dis[to]>dis[now]+edge[i].dis)
            {
                dis[to]=edge[i].dis+dis[now];
                flow[to]=min(edge[i].flow,flow[now]);
                last[to]=i;
                pre[to]=now;
                if (!vis[to])
                {
                    q.push(to); vis[to]=1;
                }
            }
        }
    }
    return pre[t]!=-1;
}
inline void MCMF(int s,int t)
{
    while (spfa(s,t))
    {
        int now=t;
        maxflow+=flow[t];
        mincost+=flow[t]*dis[t];
        while (now!=s)
        {
            edge[last[now]].flow-=flow[t];//dis . flow
            edge[last[now]^1].flow+=flow[t];
            now=pre[now];
        }
    }
}
int n,m,k,s,t,ss,a,b,S,T;

int fw[1 << 10 | 7][1 << 10 | 7];

int choose[maxn];

string ans;

bool dfs(int u) {
	if (u == 1) ans.push_back('R');
	int x = u - 1;
	for (int i = 0; i < k; ++i) if (!(x >> i & 1)) {
		int y = x | 1 << i;
		if (fw[x + 1][y + 1]) {
			fw[x + 1][y + 1]--;
			ans.push_back(char('0' + i));
			return dfs(y + 1);
		}
	}
	return u != 1;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int nn;
    cin >> k >> nn;
    n = 1 << k;
    s = 2 * n + 1;
	t = s + 1;
	S = t + 1;
	T = S + 1;

	for (int i = 1; i <= nn; ++i) {
		string s; cin >> s;
		int x = 0;
		for (int j = s.size() - 1; j >= 0; --j) x = x * 2 + s[j] - '0';
//		for (char c: s) x = x * 2 + c - '0';
		x += 1;
		choose[x] = 1;
//		see(x);
	}
	for (int i = 1; i <= n; ++i) {
		int x = i;
		if (choose[x]) {
			ins(x, x + n, 1, inf, 0);
			ins(x + n, t, 0, inf, 1);
		}
		else ins(x, x + n, 0, inf, 0);
	}
	
	for (int i = 1; i <= n; ++i) {
		int x = i - 1;
		for (int j = 0; j < k; ++j) if (!(x >> j & 1)) {
			int y = x | 1 << j;
			ins(x + 1 + n, y + 1, 0, inf, 1);
		}
	}
	
	ins(s, 1, 0, inf, 0);

    //正常建图  s为源点 t为汇点    sum为所有得下界*费用和
 
    ins(t,s,0,inf,0);
    for(int i=1;i<=t;i++)
	    if(d[i]>0)add(S,i,d[i],0);
	    else if(d[i]<0)add(i,T,-d[i],0);
    MCMF(S,T);
    cout << mincost - 1 << endl;
	
	for (int u = n + 1; u < s; ++u) {
		for (int i = head[u]; i; i = edge[i].next) {
			int v = edge[i].to;
			if (v > n) continue;
			if (i % 2) continue;
			fw[u - n][v] = edge[i].prem - edge[i].flow;
		}
	}
//	for (int i = 1; i <= n; ++i) {
//		for (int j = 1; j <= n; ++j) cout << fw[i][j] << " \n"[j == n];
//	}
	while (dfs(1));
	ans.pop_back();
	for (int i = 1; i < ans.size(); ++i) cout << ans[i] << " \n"[i == ans.size() - 1];
}
//答案即为（求出的费用+原图中边的下界*边的费用）！！！！！！！！！！！！！