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>
using namespace std;
const int maxn = 3e3 + 7;
const int INF = 0x3f3f3f3f;
struct Edge
{
    int from, to, cap, flow, cost;
};
struct MCMF
{
    int n, m, s, t;
    vector<Edge> edges;
    vector<int> G[maxn];
    int inq[maxn];
    int d[maxn]; //最短路数组
    int p[maxn]; //记录路径
    int a[maxn]; //记录流量
    void init(int n)
    {
        this->n = n;
        for (int i = 0; i < n; i++)
            G[i].clear();
        edges.clear();
    }
    void addedge(int from, int to, int cap, int cost)
    {
        edges.push_back(Edge{from, to, cap, 0, cost});
        edges.push_back(Edge{to, from, 0, 0, -cost});
        m = edges.size();
        G[from].push_back(m - 2);
        G[to].push_back(m - 1);
    }
    bool spfa(int s, int t, int &flow, int &cost)
    {
        for (int i = 0; i < n; i++)
            d[i] = INF;
        memset(inq, 0, sizeof(inq));
        d[s] = 0;
        inq[s] = 1;
        p[s] = 0;
        a[s] = INF;
        queue<int> q;
        q.push(s);
        while (!q.empty())
        {
            int u = q.front();
            q.pop();
            inq[u] = 0;
            for (int i = 0; i < G[u].size(); i++)
            {
                Edge &e = edges[G[u][i]];
                if (e.cap > e.flow && d[e.to] > d[u] + e.cost) // d[e.to] = d[u]+e.cost+h[u]-h[e.to]
                {
                    d[e.to] = d[u] + e.cost;             //松弛
                    p[e.to] = G[u][i];                   //记录上一个点
                    a[e.to] = min(a[u], e.cap - e.flow); //流量控制
                    if (!inq[e.to])
                    {
                        q.push(e.to);
                        inq[e.to] = 1;
                    }
                }
            }
        }
        if (d[t] == INF)
            return false; //不存在最短路
        // for(int i=0;i<n;i++) h[i]+=d[i];
        flow += a[t];
        cost += d[t] * a[t];
        // cost += h[t] * a[t];
        int u = t;
        while (u != s)
        {
            edges[p[u]].flow += a[t];
            edges[p[u] ^ 1].flow -= a[t];
            u = edges[p[u]].from;
        }
        return true;
    }
    int Mincost(int s, int t)
    {
        int flow = 0, cost = 0;
        while (spfa(s, t, flow, cost))
            ;
        return cost;
    }
}F;
const int inf=1e9;
int nxt[1<<11];
int d,n;
vector<int> ans;
void dfs(int u)
{
    u+=(1<<d);
    for(auto ev:F.G[u])
    {
        auto &e=F.edges[ev];
        if(e.flow>0&&e.to<(1<<d)*2)
        {
            int cur=u-(1<<d);
            if(e.to<cur) continue;
            e.flow--;
            if(e.to&&e.to<(1<<d))
            {
                for(int j=0;j<d;j++)
                {
                    if((e.to>>j&1)&&!(cur>>j&1))
                        ans.push_back(j);
                }
                dfs(e.to);
                return;
            }
        }
    }
}
int main()
{
    cin>>d>>n;
    auto getid=[&](int x,int tp){
        return x+tp*(1<<d);
    };
    int S=(1<<d)*2+1,T=S+1;
    F.init(T+1);
    for(int i=0;i<(1<<d);i++)
    {
        F.addedge(getid(i,0),getid(i,1),inf,0);
        F.addedge(getid(i,1),getid(0,0),inf,1);
        for(int j=0;j<d;j++)
        {
            if(i&(1<<j));
            else F.addedge(getid(i,1),getid(i|(1<<j),0),inf,1);
        }
    }
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        int cur=0;
        for(int j=0;j<d;j++)
        {
            if(s[j]=='1')
                cur+=(1<<j);
        }
        F.addedge(S,getid(cur,1),1,0);
        F.addedge(getid(cur,0),T,1,0);
    }
    cout<<F.Mincost(S,T)-1<<endl;
    for(auto ev:F.G[1<<d])
    {
        auto &e=F.edges[ev];
        while(e.flow>0)
        {
            //cout<<":"<<e.to<<endl;
            for(int j=0;j<d;j++)
            {
                if(e.to==(1<<j)) ans.push_back(j);
            }
            dfs(e.to);
            e.flow--;
            ans.push_back(-1);
        }
    }
    for(int i=0;i+1<ans.size();i++)
    {
        if(ans[i]==-1) cout<<"R ";
        else cout<<ans[i]<<" \n"[i+2==ans.size()];
    }

}