#include <bits/stdc++.h>
#define here printf("modassing [%s] in LINE %d\n", __FUNCTION__, __LINE__);
#define debug(x) cout << #x << ":\t" << (x) << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int maxn = 2e3 + 10;
const int maxm = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 0.0000001;

struct edge
{
    int to, next;
}e[maxm];                                    //maxm是边的最大值

int head[maxn], vis[maxn], match[maxn], match0[maxn], tol;     //head存匹配方，vis和match存被匹配方

int a[maxn], d, n, mark[maxn];
char s[100];
vector<int> vec;

void add_edge(int x, int y)
{
    e[tol].to = y;
    e[tol].next = head[x]; head[x] = tol++;
}

bool dfs(int x)
{
    for(int i = head[x]; ~i; i = e[i].next)
    {
        int v = e[i].to;                     //看看能否给x寻找到v的增广路径
        if(!vis[v])                          //如果v已经不能被挪走
        {
            vis[v] = 1;
            if(!match[v] || dfs(match[v]))   //如果v尚未匹配或者匹配了可以被挪走
            {
                match[v] = x;
                match0[x] = v;
                return true;
            }
        }
    }
    return false;
}

bool check(int x, int y)
{
    for (int i = 0; i < d; i++)
        if(((y>>i) & 1) && !((x>>i) & 1))
            return false;
    return true;
}

int cal(int x)
{
    int res = 0;
    while(x)
    {
        res += x & 1;
        x /= 2;
    }
    return res;
}

int cmp(const int& x, const int& y)
{
    return cal(x) > cal(y);
}

int main()
{
    scanf("%d %d", &d, &n);
    int cost = n - 1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s);
        for (int j = 0; j < d; j++)
            a[i] = (a[i] << 1) + (s[j] - '0');
        cost += cal(a[i]);
    }
    sort(a + 1, a + 1 + n, cmp);
    memset(head, -1, sizeof(head));

    for (int i = 1; i <= n; i++)
        for (int j = 1; j < i; j++)
        {
            if(check(a[j], a[i]))
                add_edge(i, j);
        }

    for(int i = 1; i <= n; i++)
    {
        memset(vis + 1, 0, sizeof(vis[0]) * n);      //每次需要初始化vis
        if(dfs(i))
        {
            cost--;
            cost -= cal(a[i]);
        }
    }

    for (int i = n; i >= 1; i--)
    {
        if(mark[i]) continue;
        if(vec.size()) vec.push_back(-1);
        int cur = i;
        for (int j = 0; j < d; j++)
            if((a[cur]>>j) & 1)
                vec.push_back(d - 1 - j);
        mark[cur] = 1;
        while (cur)
        {
            int v = match0[cur];
            for (int j = 0; j < d; j++)
                if(((a[v]>>j) & 1) && !((a[cur]>>j) & 1))
                    vec.push_back(d - 1 - j);
            mark[v] = 1;
            cur = v;
        }
    }

    printf("%d\n", cost);
    for(auto y: vec)
    {
        if(y == -1)  printf("R ");
        else printf("%d ", y);
    }
}
### Prompt

Please create a solution in Cpp to the following 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.

### Response

```cpp
#include <bits/stdc++.h>
#define here printf("modassing [%s] in LINE %d\n", __FUNCTION__, __LINE__);
#define debug(x) cout << #x << ":\t" << (x) << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int maxn = 2e3 + 10;
const int maxm = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 0.0000001;

struct edge
{
    int to, next;
}e[maxm];                                    //maxm是边的最大值

int head[maxn], vis[maxn], match[maxn], match0[maxn], tol;     //head存匹配方，vis和match存被匹配方

int a[maxn], d, n, mark[maxn];
char s[100];
vector<int> vec;

void add_edge(int x, int y)
{
    e[tol].to = y;
    e[tol].next = head[x]; head[x] = tol++;
}

bool dfs(int x)
{
    for(int i = head[x]; ~i; i = e[i].next)
    {
        int v = e[i].to;                     //看看能否给x寻找到v的增广路径
        if(!vis[v])                          //如果v已经不能被挪走
        {
            vis[v] = 1;
            if(!match[v] || dfs(match[v]))   //如果v尚未匹配或者匹配了可以被挪走
            {
                match[v] = x;
                match0[x] = v;
                return true;
            }
        }
    }
    return false;
}

bool check(int x, int y)
{
    for (int i = 0; i < d; i++)
        if(((y>>i) & 1) && !((x>>i) & 1))
            return false;
    return true;
}

int cal(int x)
{
    int res = 0;
    while(x)
    {
        res += x & 1;
        x /= 2;
    }
    return res;
}

int cmp(const int& x, const int& y)
{
    return cal(x) > cal(y);
}

int main()
{
    scanf("%d %d", &d, &n);
    int cost = n - 1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s);
        for (int j = 0; j < d; j++)
            a[i] = (a[i] << 1) + (s[j] - '0');
        cost += cal(a[i]);
    }
    sort(a + 1, a + 1 + n, cmp);
    memset(head, -1, sizeof(head));

    for (int i = 1; i <= n; i++)
        for (int j = 1; j < i; j++)
        {
            if(check(a[j], a[i]))
                add_edge(i, j);
        }

    for(int i = 1; i <= n; i++)
    {
        memset(vis + 1, 0, sizeof(vis[0]) * n);      //每次需要初始化vis
        if(dfs(i))
        {
            cost--;
            cost -= cal(a[i]);
        }
    }

    for (int i = n; i >= 1; i--)
    {
        if(mark[i]) continue;
        if(vec.size()) vec.push_back(-1);
        int cur = i;
        for (int j = 0; j < d; j++)
            if((a[cur]>>j) & 1)
                vec.push_back(d - 1 - j);
        mark[cur] = 1;
        while (cur)
        {
            int v = match0[cur];
            for (int j = 0; j < d; j++)
                if(((a[v]>>j) & 1) && !((a[cur]>>j) & 1))
                    vec.push_back(d - 1 - j);
            mark[v] = 1;
            cur = v;
        }
    }

    printf("%d\n", cost);
    for(auto y: vec)
    {
        if(y == -1)  printf("R ");
        else printf("%d ", y);
    }
}
```