#include <bits/stdc++.h>

#define ll long long
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i=a, _n=b; i<=_n; ++i)
#define FORD(i, a, b) for(int i=a, _n=b; i>=_n; --i)
#define REP(i, _n) for(int i=0; i<_n; ++i)
#define vi vector<int>
#define rep(i, a, b) for(int i=a, _n=b; i<=_n; ++i)
using namespace std;

const int N = 2e3, INF = 1e8;
int n, d, vis[N], mch[N];
string s[N];
vector<vector<int> > a;

pair<int, vector<pair<int, int>>> hungarian(const vector<vi> &A) {
    int n = A.size(), m = A[0].size();

    vector<int> u (n+1), v (m+1), p (m+1), way (m+1);
    for (int i=1; i<=n; ++i) {
        p[0] = i;
        int j0 = 0;
        vector<int> minv (m+1, INF);
        vector<char> used (m+1, false);
        do {
            used[j0] = true;
            int i0 = p[j0],  delta = INF,  j1;
            for (int j=1; j<=m; ++j)
                if (!used[j]) {
                    int cur = A[i0-1][j-1]-u[i0]-v[j];
                    if (cur < minv[j])
                        minv[j] = cur,  way[j] = j0;
                    if (minv[j] < delta)
                        delta = minv[j],  j1 = j;
                }
            for (int j=0; j<=m; ++j)
                if (used[j])
                    u[p[j]] += delta,  v[j] -= delta;
                else
                    minv[j] -= delta;
            j0 = j1;
        } while (p[j0] != 0);
        do {
            int j1 = way[j0];
            p[j0] = p[j1];
            j0 = j1;
        } while (j0);
    }

    vector<pair<int, int>> result;
    for (int i = 1; i <= m; ++i){
      result.push_back(make_pair(p[i], i));
    }

    int C = -v[0];

    return mp(C, result);
}
int main()
{
    ios::sync_with_stdio();
    cin.tie(0); cout.tie(0);
    // freopen("a.inp","r",stdin);

    cin >> d >> n;
    REP(i, n) cin >> s[i];

    a.assign(n, vector<int> (n, 0));

    REP(i, n) REP(j, n) {
        int value = 1;
        REP(k, d) {
            if (s[i][k] == '0' && s[j][k] == '1') value = 0;
            if (s[i][k] == '1' && s[j][k] == '1') a[i][j] -= 1;
        }
        if (!value || i == j) a[i][j] = 0;
    }

    auto tmp = hungarian(a);

    for(auto x: tmp.y) if (a[x.x-1][x.y-1]) {
        mch[x.y] = x.x;
    }

    vector<int> ans;
    FOR(i, 1, n) vis[mch[i]] = 1;
    FOR(i, 1, n) if (!vis[i]) {
        REP(k, d) if (s[i-1][k] == '1') ans.pb(k);
        for(int j=i; mch[j]!=0; j=mch[j]) {
            REP(k, d) if (s[j-1][k] != s[mch[j]-1][k]) ans.pb(k);
        }
        ans.pb(-1);
    }
    ans.pop_back();
    cout << ans.size() << endl;
    for(int x: ans) if (x!=-1) cout << x <<' '; else cout << 'R' <<' ';
}
