Problem: You are standing in front of the room with great treasures. The only thing stopping you is the door with a push-button combination lock. This lock has d buttons with digits from 0 to d - 1. Whenever you press a button, it stays pushed down. You can not pop back up just one button, but there is a "RESET" button — pressing it pops up all other buttons. Initially, no buttons are pushed down.

The door instantly opens when some specific set of digits is pushed down. Sadly, you don't know the password for it. Having read the documentation for this specific lock, you found out that there are n possible passwords for this particular lock. 

Find the shortest sequence of button presses, such that all possible passwords appear at least once during its execution. Any shortest correct sequence of button presses will be accepted.

Input

The first line contains two integers d and n (1 ≤ d ≤ 10; 1 ≤ n ≤ 2^d - 1). Next n lines describe possible passwords. Each line contains a string s_i of d zeros and ones: for all j from 1 to d the j-th character is 1 iff the button with the digit j - 1 must be pushed down.

All strings s_i are different, and each string contains at least one 1.

Output

On the first line, print the number k — the minimum number of button presses. On the second line, print k tokens, describing the sequence. Whenever you press a button with a digit, print that digit. Whenever you press "RESET", print "R".

Examples

Input


2 2
10
11


Output


2
0 1 


Input


3 4
001
111
101
011


Output


6
2 0 R 1 2 0 

Note

In the second example, the sequence 1 2 R 2 0 1 is also possible.

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>

#include <set>
#include <cmath>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;
const int N=2e3+100;
const int mod=1e9+7;
double eps=1e-5;
int n,m;
int a[N];
char s[N][N];
typedef long long INT;
typedef pair<int, int> pii;
struct edge {
    int to, capacity, cost, rev;
    edge() {}
    edge(int to,int _capacity,int _cost,int _rev):
        to(to), capacity(_capacity), cost(_cost), rev(_rev) {}
};
const int INF=0x3f3f3f3f;
struct Min_Cost_Max_Flow {
    int V, H[N + 5], dis[N +5], PreV[N +5], PreE[N + 5];
    vector<edge> G[N + 5];
    void Init(int n) {
        V = n;
        for(int i = 0; i <= V; ++i) G[i].clear();
    }
    void add_edge(int from, int to, int cap, int cost) {
        //cout<<from<<" "<<to<<" "<<cap<<" "<<cost<<endl;
        G[from].push_back(edge(to, cap, cost, G[to].size()));
        G[to].push_back(edge(from,0, -cost, G[from].size() - 1));
    }
    int minCost(int s, int t, int f) {
        int flow = 0;
        int res = 0;
        fill(H, H +1 + V, 0);
        while(f) {
            priority_queue <pii, vector<pii>, greater<pii> > q;
            fill(dis, dis + 1 + V, INF);
            dis[s] = 0;
            q.push(pii(0, s));
            while(!q.empty()) {
                pii now = q.top();
                q.pop();
                int v = now.second;
                if(dis[v] < now.first)continue;
                for(int i = 0; i < G[v].size(); ++i) {
                    edge& e = G[v][i];
                    if(e.capacity > 0 && dis[e.to] > dis[v] + e.cost + H[v] - H[e.to]) {
                        dis[e.to] = dis[v] + e.cost + H[v] - H[e.to];
                        PreV[e.to] = v;
                        PreE[e.to] = i;
                        q.push(pii(dis[e.to], e.to));
                    }
                }
            }
            if(dis[t] == INF)break;
            for(int i = 0; i <= V; ++i)H[i] += dis[i];
            int d = f;
            for(int v = t; v != s; v = PreV[v])d = min(d, G[PreV[v]][PreE[v]].capacity);
            f -= d;
            flow += d;
            res += d*H[t];
            //if(H[t]>=0)return res;
            for(int v = t; v != s; v = PreV[v]) {
                edge& e = G[PreV[v]][PreE[v]];
                e.capacity -= d;
                G[v][e.rev].capacity += d;
            }
        }
        //cout<<flow<<endl;
        return res;
    }
} ac;
int from[N],go[N];
std::vector<int> ans;
int Cal(int x){
    int ans=0;
    while(x){
        ans=ans+x%2;
        x/=2;
    }
    return ans;
}
void ok(int x){
    for(int j=0;j<m;j++){
        if(x>>j&1)ans.push_back(j);
    }
    
}
int main() {
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);
        for(int j=1;j<=m;j++){
            if(s[i][j]=='1')a[i]=a[i]+(1<<(j-1));
        }
        //cout<<i<<" "<<a[i]<<endl;
    }
    int S=n*2+1,T=n*2+2;
    ac.Init(n*2+3);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if((a[i]&a[j])==a[i]&&a[i]!=a[j])ac.add_edge(i,j+n,1,0);
        }
        ac.add_edge(S,i,1,-(1+Cal(a[i])));
        ac.add_edge(i+n,T,1,0);
    }
    ac.minCost(S,T,n);
    for(int i=n+1;i<=n+n;i++){
        for(auto nxt:ac.G[i]){
            int to=nxt.to,flow=nxt.capacity;
            //cout<<i<<"->"<<to<<" c:"<<flow<<endl;
            if(flow>0&&to>=1&&to<=n){
                from[i-n]=to;
                go[to]=i-n;
            }
        }
    }
    std::vector<int> id;
    for(int i=1;i<=n;i++){
        if(from[i]==0)id.push_back(i);
    }
    for(auto x:id){
        ok(a[x]);
        while(go[x]){
            ok(a[x]^a[go[x]]);
            x=go[x];
        }
        ans.push_back(-1);
    }
    if(ans.size())ans.pop_back();
    printf("%d\n",ans.size());
    for(int v:ans){
        if(v==-1)printf("R ");
        else printf("%d ",v);
    }
    printf("\n");
    





    
}