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 ll long long
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define fors(i, a, b) for(int i = (a); i < (b); ++i)
#define all(vec) vec.begin(),vec.end()
using namespace std;
int d, n;
int bin[1<<11];
const int maxn = 5e3;
bool cmp(int x, int y){
    return bin[x] < bin[y];
}
int con[maxn];
vector<int> g[maxn];
int vis[maxn], tim = 0;
bool dfs(int u){
    if(vis[u] == tim) return false;
    vis[u] = tim;
    for(int v: g[u]){
        if(vis[v] == tim) continue;
        vis[v] = tim;
        if(con[v] == -1 || dfs(con[v])){
            con[u] = v; con[v] = u;
            return true;
        }
    }
    return false;
}
int to[maxn];
vector<int> nd;
vector<int> ans;
void go(int id, int cur){
    int mask = nd[id];
    fors(i,0,d) if((mask>>i&1) && !(cur>>i&1)) ans.pb(i);
    if(to[id] == -1) return;
    go(to[id], mask);
}
int main()
{
    fors(i,1,1<<11) bin[i] = bin[i-lowbit(i)]+1;
    cin>>d>>n;
    fors(i,0,n){
        string s; cin>>s; reverse(all(s));
        int x =0 ; fors(i,0,s.size()) x<<=1, x|=(s[i]=='1');
        nd.pb(x);
    }
    sort(all(nd), cmp);
    fors(i,0,nd.size()){
        int x = nd[i];
        fors(j,i+1,nd.size()){
            int y = nd[j];
            if((x&y) == x) g[i].pb(j+n);
        }
        sort(all(g[i]), cmp);
        reverse(all(g[i]));
    }
    memset(con, -1, sizeof con);
    for(int i = n-1; i >= 0; --i){
        tim++;
        dfs(i);
    }
//    fors(i,0,n) cout<<"con:"<<con[i]<<endl;
//    return 0;
    memset(to, -1, sizeof to);
    fors(i,0,n){
        if(con[i]!=-1) to[i] = con[i]-n;
    }
    vector<int> st; st.clear();
    fors(i,n,2*n) if(con[i] == -1) st.pb(i-n);
    go(st[0], 0);
    fors(i,1,st.size()) ans.pb(-1), go(st[i], 0);
    cout<<ans.size()<<endl;
    for(int x:ans){
        if(x==-1) printf("R ");
        else printf("%d ", x);
    }
    printf("\n");
	return 0;
}