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 endl '\n'
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int maxn = 1e3 + 500;
string str[maxn];
struct Edge{
    int u,v,nxt,f,w;
}edge[maxn*maxn << 1];
int head[maxn*maxn<<1],cnt = -1;
void init(){
    memset(head,-1,sizeof(head));
    cnt = -1;
}
inline void add_edge(int u,int v,int f,int w){
    edge[++cnt] = {u,v,head[u],f,w};
    head[u] = cnt;
    edge[++cnt] = {v,u,head[v],0,-w};
    head[v] = cnt;
}
int s,t;
int dis[maxn*maxn<<1],flow[maxn*maxn<<1],vis[maxn*maxn<<1],pre[maxn*maxn<<1],last[maxn*maxn<<1];
inline bool spfa(int s,int t){
    memset(dis,0x3f,sizeof(int)*(t+100));
    memset(flow,0x3f,sizeof(int)*(t+100));
    memset(vis,0,sizeof(int)*(t+100));
    queue<int> q;   q.push(s);
    vis[s] = 1; dis[s] = 0; pre[t] = -1;
    while(!q.empty()){
        int u = q.front();  q.pop();
        vis[u] = 0;
        for(int i = head[u]; ~i; i = edge[i].nxt){
            Edge &e = edge[i];
            if(e.f > 0 && dis[e.v] > dis[u] + e.w){
                dis[e.v] = dis[u] + e.w;
                pre[e.v] = u;
                last[e.v] = i;
                flow[e.v] = min(flow[u], e.f);
                if(!vis[e.v]){
                    vis[e.v] = 1;
                    q.push(e.v);
                }
            }
        }
    }
    return pre[t] != -1;
}
int maxflow,mincost;
void MCMF(int s, int t){
    while(spfa(s,t)){
        int u = t;
        maxflow += flow[t];
        mincost += flow[t] * dis[t];
        while(u != s){
            edge[last[u]].f -= flow[t];
            edge[last[u] ^ 1].f += flow[t];
            u = pre[u];
        }
    }
}
int d,n;
int check_num(int i,int j){
    int num = 0;
    for(int k = 0; k < d; ++k){
        if(str[i][k] == '1' && str[j][k] == '0')  return -1;
        else if(str[i][k] != str[j][k])   ++num;
    }
    return num;
}
void print(int i,int j){
    if(i > n)   i-=n;
    if(j > n)   j-=n;
    for(int k = 0; k < d; ++k){
        if(str[i][k] != str[j][k]){
            cout << k <<' ';
        }
    }
}
void dfs(int u,int fa){
    int cnt = 0;
    for(int i = head[u]; ~i; i = edge[i].nxt){
        Edge &e = edge[i];
        if(i % 2 == 0)  continue;
        if(e.f == 1 && e.v != u){
            ++cnt;
            if(cnt > 1)    cout << "R ";
            dfs(e.v, u);
            //cout << e.v << ' ';
            if(u != t){
                print(u,e.v);
            }
        }
    }
}
int arr[maxn << 1];
int las[maxn << 1],nxt[maxn << 1];
int main()
{
    IOS;
    init();
    cin >> d >> n;
    s = 2 * n + 1, t = 2 * n + 2;
    for(int i = 0; i < d; ++i){
		str[0] += "0";
    }
    for(int i = 1; i <= n; ++i){
        cin >> str[i];
		for(int j = 0; j < d; ++j){
			if(str[i][j] == '1')	arr[i] += (1 << j);
		}
		add_edge(s, i, 1, 0);
		add_edge(i + n, t, 1, 0);
    }
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n; ++j){
			if(i == j)continue;
			if((arr[i] & arr[j]) == arr[j]) add_edge(j, i + n, 1, __builtin_popcount(arr[i]) - __builtin_popcount(arr[j]));
        }
        if(i > 0) add_edge(0, i, 1, __builtin_popcount(arr[i]));
    }
    add_edge(s , 0,  0x3f3f3f3f, 1);
    MCMF(s,t);
    for(int i = 0; i <= cnt; i += 2){
		Edge &e = edge[i];
		int u = e.u,v = e.v;
		if(u > n)	u -= n;
		if(v > n)	v -= n;
		if(e.f == 0 && e.u != s && e.v != t){
			nxt[u] = v;
			las[v] = u;
		}
    }
    cout << mincost - 1 << endl;
    bool isok = true;
	for(int i = 1; i <= n; ++i){
		if(las[i])	continue;
		if(!isok)cout << "R ";
		for(int j = i; j; j = nxt[j]){
			for(int k = 0; k < d; ++k){
				if(str[j][k] != str[las[j]][k]){
					cout << k << ' ';
				}
			}
		}
		isok = false;
    }

    return 0;
}