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:
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

struct flow_network {

    const int inf = 1e9 + 9;

    struct flow_edge {

        int from, to, cf, w;

        flow_edge() {}
        flow_edge(int a, int b, int c, int d) : from(a), to(b), cf(c), w(d) {}
    };

    int n, m, s, t;
    vector<flow_edge> edges;
    vector<vector<int>> gr;

    vector<int> d, trace;
    vector<bool> inqueue;
    queue<int> q;

    int max_matching;

    void init(int _n, int _s, int _t) {
        n = _n; s = _s; t = _t;
        edges.clear(); m = 0;
        gr.assign(n + 5, vector<int>());
        d.resize(n + 5);
        trace.resize(n + 5);
        inqueue.resize(n + 5);

    }

    void add_edge(int u, int v, int cap, int w) {
        edges.push_back(flow_edge(u, v, cap, w));
        edges.push_back(flow_edge(v, u, 0, -w));
        gr[u].push_back(m);
        gr[v].push_back(m + 1);
        m += 2;
    }

    bool spfa() {
        fill(d.begin(), d.end(), inf);
        fill(inqueue.begin(), inqueue.end(), false);
        d[s] = 0;
        q.push(s);
        inqueue[s] = true;
        while(!q.empty()) {
            int u = q.front(); q.pop();
            inqueue[u] = false;
            for(auto&id: gr[u]) {
                int v = edges[id].to, w = edges[id].w;
                if(edges[id].cf > 0 && d[v] > d[u] + w) {
                    d[v] = d[u] + w;
                    trace[v] = id;
                    if(!inqueue[v]) {
                        inqueue[v] = true;
                        q.push(v);
                    }
                }
            }
        }
        return d[t] != inf;
    }

    void find_max_matching() {
        max_matching = 0;
        while(spfa()) {
            ++max_matching;
            int cur = t;
            while(cur != s) {
                int id = trace[cur];
                --edges[id].cf; ++edges[id ^ 1].cf;
                cur = edges[id].from;
            }
        }
    }
} graph;

const int maxd = 10;
const int maxn = (1 << 10) + 5;

int d, n;
int a[maxn];

int prv[maxn], nxt[maxn];

void read_input() {
    cin >> d >> n;
    for(int i = 0; i < n; ++i) {
        a[i] = 0;
        char c;
        for(int j = 0; j < d; ++j) {
            cin >> c;
            if(c == '1') a[i] ^= (1 << j);
        }
    }
}

void link(int i, int j) {
    nxt[i] = j;
    prv[j] = i;
}

void get(int x, int y, vector<int>&ans) {
    for(int i = 0; i < d; ++i) {
        if(!(x >> i & 1) && (y >> i & 1)) {
            ans.push_back(i);
        }
    }
}

void solve() {
    int src = n * 2, snk = n * 2 + 1;
    graph.init(n * 2 + 2, src, snk);

    for(int i = 0; i < n; ++i) {
        graph.add_edge(src, i, 1, 0);
        graph.add_edge(i + n, snk, 1, 0);
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i == j) continue;
            int x = __builtin_popcount(a[i]);
            int y = __builtin_popcount(a[j]);
            if((a[i] & a[j]) == a[i]) {
                graph.add_edge(i, j + n, 1, y - x);
            }
        }
    }

    graph.find_max_matching();

    for(int i = 0; i < n; ++i){
        prv[i] = nxt[i] = -1;
    }

    for(int i = 0; i < n; ++i) {
        int j = -1;
        for(auto&id: graph.gr[i + n]) {
            int u = graph.edges[id].to;
            if(graph.edges[id].cf && u < n) {
                j = u;
                break;
            }
        }

        if(j != -1) {
            link(j, i);
        }
    }

    vector<vector<int>> chains;
    for(int i = 0; i < n; ++i) {
        if(prv[i] == -1) {
            vector<int> chain;
            int j = i;
            while(j != -1) {
                chain.push_back(j);
                j = nxt[j];
            }
            chains.push_back(chain);
        }
    }

    vector<int> ans;
    for(auto&chain: chains) {
        int lst = 0;
        for(auto&id: chain) {
            get(lst, a[id], ans);
            lst = a[id];
        }
        ans.push_back(-1);
    }
    ans.pop_back();

    cout << sz(ans) << '\n';
    for(auto&to: ans) {
        if(to == -1) cout << "R ";
        else cout << to << ' ';
    }
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}