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;
typedef long long ll;
typedef long double ld;
typedef string str;

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second
#define stie std::tie
#define vec vector
#define	forn(i, l, r) for (int i=l; i<=r; i++)
#define forb(i, r, l) for (int i=r; i>=l; i--)
#define emp empty
#define beg begin
#define ins insert
#define cle clear
#define era erase
#define que queue
#define pque priority_queue
#define mset multiset
#define deq deque
#define sta stack
#define con const
#define rsz resize
#define ass assign
#define lowb lower_bound
#define uppb upper_bound

template<class T> void mini(T& a, T b) { a = min(a, b); }
template<class T> void maxi(T& a, T b) { a = max(a, b); }
template<class T1, class T2> ostream& operator<<(ostream &out, pair<T1, T2> a) { return out << a.first << " " << a.second; }
template<class T> ostream& operator<<(ostream& out, vector<T> a) { for (auto& i : a) out << i << " "; return out; }
template<class T> ostream& operator<<(ostream& out, set<T> a) { for (auto& i : a) out << i << " "; return out; }
template<class T> ostream& operator<<(ostream& out, multiset<T> a) { for (auto& i : a) out << i << " "; return out; }
template<class T1, class T2> ostream& operator<<(ostream& out, map<T1, T2> a) { for (auto& i : a) out << i << "\n"; return out; }
template<class T1, class T2> ostream& operator<<(ostream& out, unordered_map<T1, T2> a) { for (auto& i : a) out << i << "\n"; return out; }
template<class T> ostream& operator<<(ostream& out, queue<T> a) { while (!a.empty()) { out << a.front() << " "; a.pop(); } return out; }
template<class T> ostream& operator<<(ostream& out, deque<T> a) { while (!a.empty()) { out << a.front() << " "; a.pop_front(); } return out; }
template<class T> ostream& operator<<(ostream& out, priority_queue<T> a) { while (!a.empty()) { out << a.top() << "\n"; a.pop(); } return out; }
template<class T> void out(T a) { cout << a << endl; }
template<class T1, class T2> void out(T1 a, T2 b) { cout << a << " " << b << endl; }
template<class T1, class T2, class T3> void out(T1 a, T2 b, T3 c) { cout << a << " " << b << " " << c << endl; }
template<class T1, class T2, class T3, class T4> void out(T1 a, T2 b, T3 c, T4 d) { cout << a << " " << b << " " << c << " " << d << endl; }
template<class T> void out(vector<vector<T>> a) { for (vector<T> i : a) out(i); }
template<class T> void out_(T a[], int l, int r) { for (int i = l; i <= r; i++) cout << a[i] << " "; cout << endl; }
void out() { cout << "OK" << endl; }
template<class T> void sort(vector<T>& a) { sort(a.begin(), a.end()); }
template<class T> void uniq(vector<T>& a) { sort(a); a.erase(unique(a.begin(), a.end()), a.end()); }
template<class T> vector<T> set_int(vector<T> a, vector<T> b) { sort(a); sort(b); vector<T> res; set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(res)); return res; }
clock_t start_time; void start_timer() { start_time = clock(); }
double get_time() { return (double)(clock() - start_time) / CLOCKS_PER_SEC; }
#if __SIZEOF_INT128__ >= 16
typedef __int128 LL;
istream& operator>>(istream& in, __int128& a) { int64_t b; cin >> b; a = b; return in; }
ostream& operator<<(ostream& out, const __int128 a) {
	unsigned __int128 b = a < 0 ? -a : a; char buf[128]; char* c = end(buf); do { --c; *c = "0123456789"[b % 10]; b /= 10; } while (b);
	if (a < 0) { --c; *c = '-'; } int len = end(buf) - c; out.rdbuf()->sputn(c, len); return out;
}
#endif

const int N = 2105;
const ll INF = 8e18;

struct Edge {
	int s;
	int e;
	ll cap;
	ll cost;
	ll flow;
};

vector<int> g[N];
vector<Edge> edges;
ll dis[N];
ll phi[N];
int par[N];
bool used[N];

void init_mcmf() {
	for (int i = 0; i < N; i++) {
		g[i].clear();
		dis[i] = 0;
		phi[i] = 0;
		par[i] = 0;
		used[i] = 0;
	}
	edges.clear();
}

void add_edge(int s, int e, ll cap, ll cost) {
	int sz = edges.size();
	edges.push_back({s, e, cap, cost, 0});
	edges.push_back({e, s, 0, -cost, 0});
	g[s].push_back(sz);
	g[e].push_back(sz ^ 1);
}

void bellman_ford(int src) {
	for (int i = 0; i < N; i++) {
		phi[i] = INF;
	}
	phi[src] = 0;
	while (1) { // possibly infinite cycle
		bool relax = 0;
		for (Edge& e : edges) {
            ll nw = phi[e.s] + e.cost;
			if (e.cap > e.flow && phi[e.s] < INF && phi[e.e] > nw) {
				phi[e.e] = nw;
				relax = 1;
			}
		}
		if (!relax) break;
	}
}

bool dijkstra(int src, int sink) {
	for (int i = 0; i < N; i++) {
		dis[i] = INF;
		par[i] = -1;
		used[i] = 0;
	}
	dis[src] = 0;
	priority_queue<pair<ll, int>> q;
	q.push({0, src});
	while (!q.empty()) {
		int v = q.top().se;
		q.pop();
		if (used[v]) continue;
		used[v] = 1;
		for (int i : g[v]) {
			Edge& e = edges[i];
			int u = e.e;
			ll w = e.cost + phi[v] - phi[u];
			if (e.flow < e.cap && dis[u] > dis[v] + w) {
				dis[u] = dis[v] + w;
				par[u] = i;
				q.push({-dis[u], u});
			}
		}
	}
	return par[sink] != -1;
}

pair<ll, ll> min_cost_flow(int src, int sink, ll bound = INF) {
	bellman_ford(src);
	ll flow = 0;
	ll cost = 0;
	while (dijkstra(src, sink)) {
		for (int i = 0; i < N; i++) {
			phi[i] += dis[i];
		}
		ll f = bound - flow;
		int v = sink;
		while (v != src) {
			Edge& e = edges[par[v]];
			f = min(f, e.cap - e.flow);
			v = e.s;
		}
        flow += f;
		v = sink;
		while (v != src) {
			Edge& e = edges[par[v]];
			Edge& re = edges[par[v] ^ 1];
			e.flow += f;
			re.flow -= f;
			cost += f * e.cost;
			v = e.s;
		}
    }
    return {flow, cost};
}

int a[N];
int to[N];
int from[N];
vec<int> st;
vec<int> ans;
int d;

void go(int x) {
	forn(i, 0, d-1) {
		if (x & (1 << i)) ans.pb(i);
	}
}

void Solve() {
	int n;
	cin >> d >> n;
	forn(i, 1, n) {
		str s;
		cin >> s;
		forn(j, 0, d-1) {
			if (s[j] == '1') {
				a[i] |= 1 << j;
			}
		}
	}
	forn(i, 1, n) {
		forn(j, 1, n) {
			if (i == j) continue;
			if ((a[i] & a[j]) == a[i]) {
				add_edge(i, j + n, 1, 0);
			}
		}
	}
	int src = 0;
	int sink = 2 * n + 1;
	forn(i, 1, n) {
		add_edge(src, i, 1, - __builtin_popcount(a[i]) - 1);
	}
	forn(i, n+1, 2*n) {
		add_edge(i, sink, 1, 0);
	}
	min_cost_flow(src, sink);
	for (auto e : edges) {
		int u = e.s;
		int v = e.e;
		int flow = e.flow;
		if (1 <= u && u <= n && n + 1 <= v && v <= 2 * n && flow > 0) {
			to[u] = v - n;
			from[v - n] = u;
		}
	}
	forn(i, 1, n) {
		if (from[i] == 0) {
			st.pb(i);
		}
	}
	forn(i, 0, st.size() - 1) {
		int v = st[i];
		go(a[v]);
		while (to[v]) {
			go(a[to[v]] ^ a[v]);
			v = to[v];
		}
		if (i + 1 < st.size()) {
			ans.pb(-1);
		}
	}
	cout << ans.size() << "\n";
	for (int i : ans) {
		if (i == -1) {
			cout << "R ";
		}
		else {
			cout << i << " ";
		}
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	start_timer();
	Solve();
	return 0;
}