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;
const int INF = 1e8, maxn = 4000 + 7, maxm = 4e5 + 7;
int d, n, lx[maxn], hs[maxn], S, T;
char s[maxn];

struct A{
    int x, cnt;
    bool operator < (const A& b) const{
        return cnt == b.cnt? x < b.x : cnt < b.cnt;
    }
}a[maxn];

struct Node{
    int x, y, cap, flow, w;
    Node() {}
    Node(int _x, int _y, int _cap, int _w) : x(_x), y(_y), cap(_cap), w(_w) {flow = 0;}
}node[maxm];

int fir[maxn], nxt[2 * maxm], e = 1;
void add(int x, int y, int z, int w) {
    // printf("add: %d->%d, cap = %d, cost = %d\n", x, y, z, w);
    node[++e] = Node(x, y, z, w); nxt[e] = fir[x]; fir[x] = e;
    node[++e] = Node(y, x, 0, -w);nxt[e] = fir[y]; fir[y] = e;
}

int from[maxn], zz[maxn], dis[maxn];
bool vis[maxn];
bool spfa() {
    int s = 1, t = 0, x, y, z;
    for (int i = 1; i <= T; ++i) dis[i] = INF;
    zz[++t] = S; dis[S] = 0; vis[S] = 1;
    while(s <= t) {
        x = zz[s % maxn]; ++s; vis[x] = 0;
        // if(x == T) return 1;
        for (y = fir[x]; y; y = nxt[y]) {
            if(node[y].flow >= node[y].cap || dis[z = node[y].y] <= dis[x] + node[y].w) continue;
            dis[z] = dis[x] + node[y].w; from[z] = y;
            if(!vis[z]) {
                vis[z] = 1; ++t;
                zz[t % maxn] = z;
            }
        }
    }
    return dis[T] != INF;
}

int MCMF() {
    int rs = 0, now;
    while(spfa()) {
        now = 1;
        for (int i = T; i != S; i = node[from[i]].x) {
            node[from[i]].flow += now;
            node[from[i]^1].flow -= now;
            rs += node[from[i]].w * now;
        }
    }
    return rs;
}

void get_print(int x) {
    for (int i = 0; i < d; ++i) {
        if((x >> i) & 1) printf("%d ", i);
    }
}

int main() {
    scanf("%d%d", &d, &n);
    a[0].cnt = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%s", s + 1);
        a[i].cnt = a[i].x = 0;
        for (int j = d; j; --j) {
            a[i].x = (a[i].x << 1) | (s[j] - '0');
            if(s[j] == '1') ++a[i].cnt;
        }
        a[0].cnt += a[i].cnt;
    }
    sort(a + 1, a + n + 1);
    S = (n << 1) + 1; T = S + 1;
    for (int i = 1; i <= n; ++i) {
        add(S, i, 1, -1);
        add(i + n, T, 1, 0);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if((a[i].x & a[j].x) == a[i].x) 
                add(i, j + n, 1, -a[i].cnt);
        }
    }
    int rs = MCMF();
    printf("%d\n", a[0].cnt + n + rs - 1);

    for (int i = 1; i <= n; ++i) {
        for (int y = fir[i], z; y; y = nxt[y]) {
            if((z = node[y].y) >= S || z <= n) continue;
            if(node[y].flow == 0) continue;
            lx[i] = z - n;
            break;
        }
    }
    int fl = 0;
    for (int i = 1; i <= n; ++i) {
        if(hs[i]) continue;
        if(fl == 1) printf("R ");
        else fl = 1;
        get_print(a[i].x);
        for (int j = i; j; j = lx[j]) {
            hs[j] = 1;
            if(!lx[j]) break;
            get_print(a[j].x ^ a[lx[j]].x);
        }
    }
    printf("\n");
    return 0;
}
/*
add: 5->1, cap = 1, cost = -1
add: 3->6, cap = 1, cost = 0
add: 5->2, cap = 1, cost = -1
add: 4->6, cap = 1, cost = 0
add: 1->4, cap = 1, cost = -2
*/