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 MAX_N = 1 << 10 | 5;
const int MAX_V = MAX_N * 2;
const int MAX_E = MAX_N * MAX_N;
const int INF32 = 1e9;

int N, D, ans;
int pc[MAX_N], a[MAX_N];
int E, S, T, Flow, Cost;
int dis[MAX_V], pre[MAX_V], elast[MAX_V], inq[MAX_V];
struct Edge {
    int y, cap, cost, next;
} e[MAX_E];

inline void add_edge(int x, int y, int cap, int cost) {
    e[E].y = y;
    e[E].cap = cap;
    e[E].cost = cost;
    e[E].next = elast[x];
    elast[x] = E ++;
    e[E].y = x;
    e[E].cap = 0;
    e[E].cost = -cost;
    e[E].next = elast[y];
    elast[y] = E ++;
}
int spfa_flow() {
    for (int i = 1; i <= T; i ++) {
        dis[i] = -INF32, pre[i] = 0, inq[i] = 0;
    }
    dis[S] = 0, inq[S] = 1;
    queue<int> q;
    q.push(S);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        inq[u] = 0;
        for (int j = elast[u]; j; j = e[j].next) {
            int v = e[j].y;
            if (e[j].cap && dis[v] < dis[u] + e[j].cost) {
                dis[v] = dis[u] + e[j].cost;
                pre[v] = j;
                if (!inq[v]) {
                    inq[v] = 1;
                    q.push(v);
                }
            }
        }
    }
    if (dis[T] < 0) return 0;
    int f = INF32;
    for (int v = T; v != S; v = e[pre[v] ^ 1].y) {
        f = min(f, e[pre[v]].cap);
    }
    Flow += f, Cost += f * dis[T];
    for (int v = T; v != S; v = e[pre[v] ^ 1].y) {
        e[pre[v]].cap -= f;
        e[pre[v] ^ 1].cap += f;
    }
    return f;
}

int main() {
    scanf("%d%d", &D, &N);
    for (int i = 1; i < 1 << D; i ++) {
        pc[i] = pc[i >> 1] + (i & 1);
    }
    for (int i = 1; i <= N; i ++) {
        char buf[15];
        scanf("%s", buf + 1);
        for (int j = D; j >= 1; j --) {
            a[i] = a[i] << 1 | buf[j] - '0';
        }
        ans += pc[a[i]] + 1;
    }
    E = 2, S = N + N + 1, T = S + 1;
    for (int i = 1; i <= N; i ++) {
        add_edge(S, i, 1, 0);
    }
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= N; j ++) {
            if (a[i] < a[j] && ((a[i] ^ a[j]) & a[i]) == 0) {
                add_edge(i, j + N, 1, pc[a[i]] + 1);
            }
        }
    }
    for (int i = 1; i <= N; i ++) {
        add_edge(i + N, T, 1, 0);
    }
    while (spfa_flow());
    ans -= Cost + 1;
    for (int i = 1; i <= N; i ++) {
        pre[i] = inq[i] = 0;
    }
    for (int i = 2; i < E; i += 2) {
        int x = e[i ^ 1].y, y = e[i].y;
        if (x == S || x == T) continue;
        if (y == S || y == T) continue;
        if (!e[i].cap) {
            pre[y - N] = x;
            inq[x] = y - N;
        }
    }
    vector<int> op;
    for (int i = 1; i <= N; i ++) {
        if (pre[i]) continue;
        for (int x = 0, y = i; y; x = y, y = inq[y]) {
            int xx = a[x], yy = a[y];
            for (int j = 0; j < D; j ++) {
                if ((~xx >> j & 1) && (yy >> j & 1)) {
                    op.push_back(j);
                }
            }
        }
        op.push_back(-1);
    }
    op.pop_back();
    printf("%d\n", (int)op.size());
    for (int i = 0; i < (int)op.size(); i ++) {
        if (op[i] == -1) {
            printf("R");
        } else {
            printf("%d", op[i]);
        }
        printf("%c", i + 1 < (int)op.size() ? ' ' : '\n');
    }
    return 0;
}