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;
namespace kn {
    int n, k;
    vector<vector<int> > g;
    vector<int> mt;
    vector<char> used;

    void ini() {
        g.resize(n);
    }

    bool try_kuhn(int v) {
        if (used[v]) return false;
        used[v] = true;
        for (size_t i = 0; i < g[v].size(); ++i) {
            int to = g[v][i];
            if (mt[to] == -1 || try_kuhn(mt[to])) {
                mt[to] = v;
                return true;
            }
        }
        return false;
    }

    void kn(const vector<int> &por) {
        mt.assign(k, -1);
        for (int v : por) {
            used.assign(n, false);
            try_kuhn(v);
        }
    }

//    int main() {
//        ... чтение графа ...
//
//
//        for (int i=0; i<k; ++i)
//            if (mt[i] != -1)
//                printf ("%d %d\n", mt[i]+1, i+1);
//    }

}

int main() {
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);

    int d, n;
    cin >> d >> n;

    vector<string> msk(n);
    vector<int> x(n);
    vector<int> w(n);

    for (int i = 0; i < n; i++) {
        cin >> msk[i];
        x[i] = 0;
        for (int j = 0; j < d; j++) {
            x[i] *= 2;
            x[i] += msk[i][j] - '0';
        }
        w[i] = __builtin_popcount(x[i]);
    }

    vector<int> por(n);
    iota(por.begin(), por.end(), 0);
    sort(por.begin(), por.end(), [&](int i, int j) {
        return w[i] > w[j];
    });

    kn::n = n;
    kn::k = n;
    kn::ini();

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (x[i] < x[j]) {
                if ((x[i] & x[j]) == x[i]) {
                    kn::g[i].push_back(j);
                }
            }
        }
    }

    kn::kn(por);

    vector<int> is_first(n, 1);
    vector<int> nxt(n, -1);

    for (int i = 0; i < n; i++) {
        if (kn::mt[i] != -1) {
            nxt[kn::mt[i]] = i;
            is_first[i] = 0;
        }
    }

    vector<int> moves_res;
    for (int i = 0; i < n; i++) {
        if (is_first[i]) {
            int val = 0;
            int pos = i;
            while (pos != -1) {
                int to = x[pos];
                for (int j = 0; j < d; j++) {
                    if ((to & (1 << j)) && (!(val & (1 << j)))) {
                        moves_res.push_back(d - j - 1);
                    }
                }
                pos = nxt[pos];
                val = to;
            }
            moves_res.push_back(-1);
        }
    }
    moves_res.pop_back();

    cout << moves_res.size() << "\n";
    for (auto x : moves_res) {
        if (x == -1) {
            cout << "R" << ' ';
        } else {
            cout << x << ' ';
        }
    }
    return 0;
}