#include <bits/stdc++.h>
#define here printf("modassing [%s] in LINE %d\n", __FUNCTION__, __LINE__);
#define debug(x) cout << #x << ":\t" << (x) << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int maxn = 2e3 + 10;
const int maxm = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 0.0000001;

struct edge
{
    int to, next;
}e[maxm];                                    //maxm是边的最大值

int head[maxn], vis[maxn], match[maxn], match0[maxn], tol;     //head存匹配方，vis和match存被匹配方

int a[maxn], d, n, mark[maxn];
char s[100];
vector<int> vec;

void add_edge(int x, int y)
{
    e[tol].to = y;
    e[tol].next = head[x]; head[x] = tol++;
}

bool dfs(int x)
{
    for(int i = head[x]; ~i; i = e[i].next)
    {
        int v = e[i].to;                     //看看能否给x寻找到v的增广路径
        if(!vis[v])                          //如果v已经不能被挪走
        {
            vis[v] = 1;
            if(!match[v] || dfs(match[v]))   //如果v尚未匹配或者匹配了可以被挪走
            {
                match[v] = x;
                match0[x] = v;
                return true;
            }
        }
    }
    return false;
}

bool check(int x, int y)
{
    for (int i = 0; i < d; i++)
        if(((y>>i) & 1) && !((x>>i) & 1))
            return false;
    return true;
}

int cal(int x)
{
    int res = 0;
    while(x)
    {
        res += x & 1;
        x /= 2;
    }
    return res;
}

int cmp(const int& x, const int& y)
{
    return cal(x) > cal(y);
}

int main()
{
    scanf("%d %d", &d, &n);
    int cost = n - 1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s);
        for (int j = 0; j < d; j++)
            a[i] = (a[i] << 1) + (s[j] - '0');
        cost += cal(a[i]);
    }
    sort(a + 1, a + 1 + n, cmp);
    memset(head, -1, sizeof(head));

    for (int i = 1; i <= n; i++)
        for (int j = 1; j < i; j++)
        {
            if(check(a[j], a[i]))
                add_edge(i, j);
        }

    for(int i = 1; i <= n; i++)
    {
        memset(vis + 1, 0, sizeof(vis[0]) * n);      //每次需要初始化vis
        if(dfs(i))
        {
            cost--;
            cost -= cal(a[i]);
        }
    }

    for (int i = n; i >= 1; i--)
    {
        if(mark[i]) continue;
        if(vec.size()) vec.push_back(-1);
        int cur = i;
        for (int j = 0; j < d; j++)
            if((a[cur]>>j) & 1)
                vec.push_back(d - 1 - j);
        mark[cur] = 1;
        while (cur)
        {
            int v = match0[cur];
            for (int j = 0; j < d; j++)
                if(((a[v]>>j) & 1) && !((a[cur]>>j) & 1))
                    vec.push_back(d - 1 - j);
            mark[v] = 1;
            cur = v;
        }
    }

    printf("%d\n", cost);
    for(auto y: vec)
    {
        if(y == -1)  printf("R ");
        else printf("%d ", y);
    }
}