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 rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 2000
#define mod 1000000007
#define inf 0x3f3f3f3f
template<class T> bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int a[maxn+5];
vi e[maxn+5];

int from[maxn+5];
bool used[maxn+5],matched[maxn+5];

bool match(int now)
{
    for(auto v: e[now]) if(used[v]==0)
    {
        used[v]=1;
        if(from[v]==-1 || match(from[v])) {from[v]=now; return 1;}
    }
    return 0;
}

int main()
{
    int d,m; scanf("%d%d",&d,&m);
    rep(i,1,m) 
    {
        char s[15]; scanf("%s",s);
        int x=0;
        rep(i,0,d-1) x|=(s[i]-'0')<<i;
        a[i]=x;
    }
    sort(a+1,a+m+1,[](int x,int y){
        return __builtin_popcount(x)>__builtin_popcount(y);
    });
    rep(i,1,m) rep(j,1,i-1) if((a[i]&a[j])==a[i]) e[i].pb(j);
    
    int tot=0;
    rep(i,1,m) from[i]=-1;
    rep(i,1,m) 
    {
        rep(i,1,m) used[i]=0;
        matched[i]=match(i);
        tot+=matched[i]==0;
    }
    int ans=-1;
    rep(i,1,m) if(matched[i]==0)
    {
        ans+=__builtin_popcount(a[i])+1;
    }
    printf("%d\n",ans);
    rep(i,1,m) if(matched[i]==0)
    {
        int now=i;
        vi tmp;
        while(now!=-1)
        {
            tmp.pb(a[now]);
            now=from[now];
        }
        tmp.pb(0);
        reverse(tmp.begin(),tmp.end());
        int N=tmp.size();
        rep(i,1,N-1)
        {
            int x=tmp[i]^tmp[i-1];
            while(x) 
            {
                int d=__builtin_ctz(x);
                printf("%d ",d);
                x^=1<<d;
            }
        }
        if(--tot) printf("R ");
        else puts("");
    }
    return 0;
}