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>
#ifdef miaojie
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#else
  #define dbg(...)
#endif
using namespace std;
const int maxn=1e5+22;
const int maxm=5e6+22;
const int inf=1e9;

int d, N;
int a[maxn], need[maxn], loger[maxn], id[2500][2500];
vector<int>ans, v[maxn];

int head[maxn],tot=1,n,m;
struct Edge{
	int to,nxt,flow,cost;
}edge[maxm];

void init(){ memset(head,0,sizeof(head)); tot=1; memset(id, -1, sizeof(id));}
int add(int x,int y,int f,int c){
    dbg(x, y, f, c);
	edge[++tot]=Edge{y,head[x],f,c};
	head[x]=tot;
	edge[++tot]=Edge{x,head[y],0,-c};
	head[y]=tot;
	return tot - 1;
}

int vis[maxn], cost[maxn], pre[maxn], flow[maxn], last[maxn], mf, mc, s, t;
bool spfa(int s,int t){
	for(int i=0;i<maxn;i++){
		cost[i]=flow[i]=inf;
		vis[i]=0;
	}
	queue<int>q; q.push(s); vis[s]=1; cost[s]=0; pre[t]=-1;
	while(!q.empty()){
		int now=q.front(); q.pop(); vis[now]=0;
		for(int i=head[now];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(edge[i].flow>0 && cost[v]>cost[now]+edge[i].cost){
				cost[v]=cost[now]+edge[i].cost;
				pre[v]=now;
				last[v]=i;
				flow[v]=min(flow[now],edge[i].flow);
				if(!vis[v]){
					vis[v]=1;
					q.push(v);
				}
			}
		}
	}
	return pre[t]!=-1;
}

void mcmf(){
	mc=mf=0;
	while(spfa(s,t)){
		int now=t;
		mf+=flow[t]; mc+=flow[t]*cost[t];
		while(now!=s){
			edge[last[now]].flow-=flow[t];
			edge[last[now]^1].flow+=flow[t];
			dbg(last[now], last[now] ^ 1, flow[t]);
			now=pre[now];
		}
	}
}

void dfs(int u) {
    int tmp = v[u].back();
    dbg(u, tmp);
    v[u].pop_back();
    if(tmp == n) ans.push_back(-1);
    else {
        ans.push_back(tmp - u);
        dbg(tmp - u);
        dfs(tmp);
    }
}

void init_log(int N) {
	loger[1] = 0;
	for(int i = 2; i <= N; i++){
		loger[i] = loger[i-1];
		if((1 << loger[i] + 1) == i) ++loger[i];
	}
}
int main(){
    scanf("%d %d", &d, &N);
	for (int i = 1; i <= N; i++) {
	    char str[20];
	    scanf("%s", str + 1);
	    int bas = 1, num = 0;
	    for (int j = d; j >= 1; j--) {
	        if(str[j] == '1') num += bas;
	        bas *= 2;
        }
        a[i] = num;
        need[num] = 1;
    }    
	init();
	init_log(100000);
	n = 1 << d;
	s = 2 * n + 1, t = 2 * n + 2;
	for (int i = 0; i < n; i++) {
	    if(need[i]) {
    	   add(s, i * 2 + 1, 1, 0);
	       add(i * 2, t, 1, 0);
        }
	    id[i][n] = add(i * 2 + 1, 2 * n, inf, 1);
	    add(i * 2, i * 2 + 1, inf, 0);
    }
   
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if((__builtin_popcount(j) - __builtin_popcount(i) == 1) && ((i & j) == i)) {
                id[i][j] = add(i * 2 + 1, j * 2, inf, 1);
                dbg(i, j);
            }    
        }
    }
    add(2 * n, 0, inf, 0);
//	cout << "graph done\n";
	mcmf();
//	printf("mc mf = %d %d\n", mc , mf);
	
	for (int i = 0; i < n; i++) {
	    for (int j = i + 1; j <= n; j++) {
	        
	        if(id[i][j] == -1) continue;
	        int fl = edge[id[i][j] ^ 1].flow;
	      dbg(i, j, id[i][j] ^ 1, fl);
	        for (int k = 1; k <= fl; k++) v[i].push_back(j);
        }
    }
    
  //  cout << "?????????????";
    while((int)v[0].size()) {
        dfs(0);
      //  dbg((int)v[0].size());
    }
  //   cout << "?????????????";
    printf("%d\n", (int)ans.size() - 1);
    ans.pop_back();
    for (auto x : ans) {
        if(x == -1) printf("R");
        else {           
            printf("%d", d - 1 - loger[x]);
        }
        printf(" ");
    }
	return 0;
}