#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;
const int N = 2222;

int A[N];
vector<int> adj[N];
vector<bool> visited(N);
int match[N];

bool dfs(int cur) {
    visited[cur] = 1;
    for (auto &nxt : adj[cur]) {
        if (match[nxt] == -1 || (!visited[match[nxt]] && dfs(match[nxt]))) {
            match[cur] = nxt;
            match[nxt] = cur;
            return 1;
        }
    }
    return 0;
}


signed main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int d,n; cin>>d>>n;
    char buf[15];
    for (int i=1; i<=n; i++) {
        cin>>buf;
        A[i] = strtol(buf, NULL, 2);
    }

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (i==j) continue;
            if ((A[i]&A[j]) == A[i]) {
                adj[i].pb(j+n);
            }

        }
    }

    vector<pi> v(n);
    for (int i=1; i<=n; i++) {
        v[i-1] = pi(__builtin_popcount(A[i]), i);
    }
    sort(all(v), greater<pi>());

    memset(match, -1, sizeof match);
    for (auto &[_, i] : v) {
        fill(all(visited), 0);
        dfs(i);
    }

    string res;
    bool flag = 0;
    vector<bool> chk(n+5, 0);
    for (auto &[_, i] : v) {
        if (chk[i]) continue;
        vector<int> track;
        int cur = i + n;
        while (1) {
            track.pb(A[cur - n]);
            chk[cur - n] = 1;
            cur = match[cur];
            if (cur == -1) break;
            assert(cur >= 1 && cur <= n);
            cur += n;
        }
        track.pb(0);
        reverse(all(track));
        if (flag) res.pb('R');
        flag = 1;
        for (int j=0; j<sz(track)-1; j++) {
            int msk = track[j] ^ track[j+1];
            for (int k=0; k<d; k++) {
                if (msk & (1<<k)) {
                    res.pb('0' + d - 1 - k);
                }
            }
        }
    }
    cout<<sz(res)<<'\n';
    for (auto &i : res) cout<<i<<' ';
    cout<<'\n';
    return 0;
}