#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
#define mid ((l+r)>>1)
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define fors(i, a, b) for(int i = (a); i < (b); ++i)
#define all(vec) vec.begin(),vec.end()
using namespace std;
int d, n;
int bin[1<<11];
const int maxn = 5e3;
bool cmp(int x, int y){
    return bin[x] < bin[y];
}
int con[maxn];
vector<int> g[maxn];
int vis[maxn], tim = 0;
bool dfs(int u){
    if(vis[u] == tim) return false;
    vis[u] = tim;
    for(int v: g[u]){
        if(vis[v] == tim) continue;
        vis[v] = tim;
        if(con[v] == -1 || dfs(con[v])){
            con[u] = v; con[v] = u;
            return true;
        }
    }
    return false;
}
int to[maxn];
vector<int> nd;
vector<int> ans;
void go(int id, int cur){
    int mask = nd[id];
    fors(i,0,d) if((mask>>i&1) && !(cur>>i&1)) ans.pb(i);
    if(to[id] == -1) return;
    go(to[id], mask);
}
int main()
{
    fors(i,1,1<<11) bin[i] = bin[i-lowbit(i)]+1;
    cin>>d>>n;
    fors(i,0,n){
        string s; cin>>s; reverse(all(s));
        int x =0 ; fors(i,0,s.size()) x<<=1, x|=(s[i]=='1');
        nd.pb(x);
    }
    sort(all(nd), cmp);
    fors(i,0,nd.size()){
        int x = nd[i];
        fors(j,i+1,nd.size()){
            int y = nd[j];
            if((x&y) == x) g[i].pb(j+n);
        }
        //sort(all(g[i]), cmp);
        //reverse(all(g[i]));
    }
    memset(con, -1, sizeof con);
    for(int i = n-1; i >= 0; --i){
        tim++;
        dfs(i);
    }
//    fors(i,0,n) cout<<"con:"<<con[i]<<endl;
//    return 0;
    memset(to, -1, sizeof to);
    fors(i,0,n){
        if(con[i]!=-1) to[i] = con[i]-n;
    }
    vector<int> st; st.clear();
    fors(i,n,2*n) if(con[i] == -1) st.pb(i-n);
    go(st[0], 0);
    fors(i,1,st.size()) ans.pb(-1), go(st[i], 0);
    cout<<ans.size()<<endl;
    for(int x:ans){
        if(x==-1) printf("R ");
        else printf("%d ", x);
    }
    printf("\n");
	return 0;
}
