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:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <set>
#include <limits>
#include <random>
#include <functional>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>

using namespace std;

const int N = 1030;
const int M = 1030;
const int MOD = 1000000007;
const int INF = 1009000999;
const ll LINF = (1ll << 60) + 1337;
const ld EPS = 0.00000001;

int cnt(string a) {
    int cnt = 0;
    for (auto& i : a) if (i == '1') cnt++;
    return cnt;
}

int mark[N], r[N];
vi g[N];

bool dfs(int v) {
    if (mark[v]) return false;
    mark[v] = 1;
    for (auto& i : g[v]) {
        if (r[i] == -1 || dfs(r[i])) {
            r[i] = v;
            return true;
        }
    }
    return false;
}

vector<int> ans;

void get_path(string a, string b) {
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == '0' && b[i] == '1') ans.push_back(i);
    }
}

bool can(string a, string b) {
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == '1' && b[i] == '0') return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
    //freopen("line3.in", "r", stdin); freopen("line3.out", "w", stdout);
#endif
    fill(r, r + N, -1);
    int d, n;
    cin >> d >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), [&](string a, string b) {
        return cnt(a) < cnt(b);
    });
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (can(a[i], a[j])) {
                g[i].push_back(j);
            }
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (dfs(i)) fill(mark, mark + n, 0);
    }
    fill(mark, mark + n, 0);
    for (int i = n - 1; i >= 0; i--) {
        if (mark[i]) continue;
        vi path;
        {
            int j = i;
            while (j != -1) {
                mark[j] = 1;
                path.push_back(j);
                j = r[j];
            }
            reverse(path.begin(), path.end());
        }
        if (!ans.empty()) ans.push_back(-1);
        string pref(d, '0');
        for (auto& j : path) {
            get_path(pref, a[j]);
            pref = a[j];
        }
    }
    cout << ans.size() << "\n";
    for (auto& i : ans) {
        if (i == -1) cout << "R ";
        else cout << i << " ";
    }
}


/*
    Important stuff
    - int overflow
    - array bounds
    - special cases (n=1, max n) maybe adhoc problem
    - doubles are read for a long time (4 * 10 ^ 5 danger GNU vs MS ICPC 2020 1/4)
    - don't get stuck on one approach
    - don't get stuck on one problem
    - recheck submissions if near the end of the tournament and there is nothing to do
    - do something instead of nothing and stay organized
*/