#include<bits/stdc++.h>
using namespace std;
const int maxn = 4010;

vector<int> G[maxn];
bool vis[maxn];
int link[maxn];
int m;
int a[maxn];
int n, d;
int to[maxn];

inline void addedge(int from,int to) {
    G[from].push_back(to);
    G[to].push_back(from);
    //cerr << from << " " << to << "\n";
}

bool dfs(int u) {
    vis[u] = 1;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (!vis[v]) {
            vis[v] = 1;
            if (link[v] == -1 || dfs(link[v])) {
                link[v] = u;
                link[u] = v;
                return true;
            }
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> d >> n;
    memset(link, -1, sizeof(link));
    for(int i = 1; i <= n; i++){
        string s;
        cin >> s;
        int cnt = 0;
        for(int j = 0; s[j]; j++){
            cnt += (1 << j) * (s[j] - '0');
        }
        a[i] = cnt;
    }
    sort(a + 1, a + n + 1, [&](int x, int y){
        return __builtin_popcount(x) < __builtin_popcount(y);
    });
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i != j && (a[i] & a[j]) == a[i]){
                addedge(i, j + n);
            }
        }
    }

    for(int i = n; i; i--){
        memset(vis, 0, sizeof(vis));
        dfs(i);
    }

    for(int i = 1; i <= n; i++){
        if(link[i] != -1){
            to[i] = link[i] - n;
        }
    }

    memset(vis, 0, sizeof(vis));

    vector<int> res;
    for (int i = 1; i <= n; i += 1){
        if(!vis[i]){
            int p = i;
            for(int j = 0; j < d; j++){
                if(a[i] >> j & 1) res.emplace_back(j);
            }
            while(1){
                vis[p] = 1;
                if(vis[to[p]] || to[p] == 0) break;
                for(int j = 0; j < d; j++){
                    if((a[p] ^ a[to[p]]) >> j & 1) res.emplace_back(j);
                }
                p = to[p];
            }
            res.emplace_back(-1);
        }
    }
    res.pop_back();
    cout << res.size() << "\n";
    for(auto it : res){
        if(it == -1) cout << "R ";
        else cout << it << " ";
    }
    cout << "\n";




    return 0;
}