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;
namespace KM{
const int maxn = 1e3 + 50;
const int INF = 0x3f3f3f3f;
int n; //点数
int cost[maxn][maxn];
int lx[maxn], ly[maxn], match[maxn], slack[maxn];
int pprev[maxn];
bool vy[maxn];
void augment(int root)
{
    memset(vy, 0, sizeof(vy));
    memset(slack, 0x3f, sizeof(slack));
    int py;
    match[py = 0] = root;
    do
    {
        vy[py] = true;
        int x = match[py], yy;
        int delta = INF;
        for (int y = 1; y <= n; y++)
        {
            if (!vy[y])
            {
                if (lx[x] + ly[y] - cost[x][y] < slack[y])
                    slack[y] = lx[x] + ly[y] - cost[x][y], pprev[y] = py;
                if (slack[y] < delta)
                    delta = slack[y], yy = y;
            }
        }
        for (int y = 0; y <= n; y++)
        {
            if (vy[y])
                lx[match[y]] -= delta, ly[y] += delta;
            else
                slack[y] -= delta;
        }
        py = yy;
    } while (match[py] != -1);
    do
    {
        int pre = pprev[py];
        match[py] = match[pre], py = pre;
    } while (py);
}
int KM()
{
    for (int i = 1; i <= n; i++)
    {
        lx[i] = ly[i] = 0;
        match[i] = -1;
        for (int j = 1; j <= n; j++)
            lx[i] = max(lx[i], cost[i][j]);
    }
    int ans = 0;
    for (int root = 1; root <= n; root++)
        augment(root);
    for (int i = 1; i <= n; i++)
        ans += lx[i], ans += ly[i];
    return ans;
}
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d,n;
    cin>>d>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        for(int j=0;j<d;j++) a[i]|=(s[j]-'0')<<j;
    }
    sort(a.begin(),a.end());
    KM::n=n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int cc=__builtin_popcount(a[i]);
        for(int j=0;j<n;j++)
        {
            if(i==j) continue;
            if((a[i]&a[j])==a[i])
                KM::cost[i+1][j+1]=cc+1;
            //else KM::mp[i+1][j+1]=-KM::inf;
        }
        sum+=cc+1;
    }
    int ans=KM::KM();
    //cout<<sum<<endl;
    //cout<<ans<<endl;
    cout<<sum-ans-1<<endl;
    //for(int i=0;i<n;i++) cout<<i<<":"<<KM::match[i+1]<<endl;
    vector<int> nxt(n,-1);
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(KM::cost[KM::match[i]][i]&&KM::match[i]<i)
        {
            nxt[KM::match[i]-1]=i-1;
        }
        //cout<<KM::cost[KM::match[i]][i]<<endl;
        //cout<<i-1<<":"<<KM::match[i]-1<<" "<<nxt[i-1]<<endl;
        //else cnt++;
    }
    cnt=count(nxt.begin(),nxt.end(),-1);
    vector<int> vis(n);
    int cc=0;
    for(int i=0;i<n;i++)
    {
        if(!vis[i])
        {
            cc++;
            int pre=0;
            int cur=i;
            while(!vis[cur])
            {
                vis[cur]=1;
                for(int j=0;j<d;j++)
                {
                    if((a[cur]>>j&1)&&!(pre>>j&1)) cout<<j<<" ";
                }
                pre=a[cur];
                cur=nxt[cur];
                if(cur==-1) break;
            }
            if(cc==cnt) cout<<'\n';
            else cout<<"R ";
        }
    }
}