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 <bits/stdc++.h>

#define fi first
#define se second

using namespace std;

const int N = 100100;
const int mod = 998244353;

const int MAXN = 5e3+10;

typedef long long ll;
typedef unsigned long long ull;
int inf_int=1e9;
ll inf_ll=1e17;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
struct Edge{
    int a,b,c,flow,cost;
};
struct MIN_FLOW{
    vector<Edge> e;
    vector<int> g[MAXN];
    int n,s,t;

    int id[MAXN];
    ll dis[MAXN];
    int from[MAXN];
    void init(int N,int S,int T){
        n= N;
        s= S;
        t=T;
    }
    int add_edge(int a,int b,int c,int cost){
        int id = e.size();
        Edge e1 = {a,b,c,0,cost};
        Edge e2 = {b,a,0,0,-cost};
        g[a].pb(e.size());
        e.pb(e1);
        g[b].pb(e.size());;
        e.pb(e2);
        return id;
    }

    ll get_val(int k){
        int flow = 0;
        ll cost = 0;

        while(1){
            queue<int> q;
            fill(id,id+n,0);
            fill(dis,dis+n,inf_ll);
            dis[s]=0;
            id[s]=1;
            q.push(s);
            while(!q.empty()){
                int v = q.front(); q.pop();
                id[v] = 0;
                for(int ind:g[v]){
                    Edge& edge = e[ind];
                    int to = edge.b;
                    if(edge.c >edge.flow && dis[edge.b] > dis[v] + edge.cost){
                        if(id[to] == 0){
                            q.push(to);
                            id[to] = 1;
                        }
                        dis[to] = dis[v] + edge.cost;
                        from[to] = ind;
                    }
                }

            }
            if(dis[t]==inf_ll)
                break;

            int addflow = min(inf_int,k-flow);
            int v = t;
            while(v!=s){
                int ind = from[v];
                addflow = min(addflow,e[ind].c - e[ind].flow);
                v = e[ind].a;
            }

            v = t;
            while(v!=s){
                int ind = from[v];
                cost += 1ll*e[ind].cost * addflow;
                e[ind].flow+=addflow;
                e[ind^1].flow-=addflow;
                v = e[ind].a;
            }
            flow+=addflow;
            if(flow==k)
                break;
        }

        if(flow < k){
                return -1;
        }
        return cost;
    }

} flow;

bool fucked[N];
vector < int > v[N];

int main()
{
        #ifdef zxc
                freopen("input.txt", "r", stdin);
                freopen("output.txt", "w", stdout);
        #endif
        ios_base::sync_with_stdio(0);

        int d, n;
        cin >> d >> n;
        vector < int > a(n, 0);
        for(int i = 0; i < n; i++){
                string s;
                cin >> s;
                for(int j = 0; j < d; j++){
                        if(s[j] == '1'){
                                a[i] |= (1 << j);
                        }
                }
        }
        flow.init(2 * n + 10, 0, 2 * n + 1);

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                        if(i != j && (a[i] & a[j]) == a[i]){
                                flow.add_edge(i + 1, n + j + 1, 1, __builtin_popcount(a[i] ^ a[j]));
                        }
                }
                flow.add_edge(0, n + i + 1, 1, __builtin_popcount(a[i]) + 1);

                flow.add_edge(0, i + 1, 1, 0);

                flow.add_edge(n + i + 1, 2 * n + 1, 1, 0);
        }

        int res = flow.get_val(n) - 1;
        cout << res << "\n";

        for(auto p: flow.e){
                if(p.flow > 0 && p.cost > 0){
                        v[p.a].push_back(p.b - n);
                }
        }
        int put = 0;
        for(int x: v[0]){
                if(put){
                        cout << "R ";
                }
                put = 1;

                int cur = 0, y = x;
                while(true){
                        for(int i = 0; i < d; i++){
                                if((cur ^ a[y - 1]) & (1 << i)){
                                        cout << i << " ";
                                }
                        }
                        if(v[y].empty()){
                                break;
                        }
                        assert(v[y].size() == 1);
                        cur = a[y - 1];
                        y = v[y][0];
                }
        }
}