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 JAVA):

Solution:
import java.util.*;
import java.io.*;

public class B1510 {
	static int[][] adjMatrix;
	static final int INF = (int) 1e9;
	static int V, s, t; // s != t
	static int[][] res; // instead of res, you can use c[][], f[][] so as not to destroy the graph
	static int[][] cost;
	static int[] p, d, nodes; // res (residual) = c (capacity) - f (flow)
	static ArrayList<Integer>[] adjList;

	static void addEdge(int u, int v, int c) {
		res[u][v] = 1;
		cost[u][v] = c;
		cost[v][u] = -c;
		adjMatrix[u][v] = 1;
		adjList[u].add(v);
		adjList[v].add(u);
	}

	static int edmondsKarp() // O(min(VE^2, flow * E)) for adjList, O(V^3E)
	{
		int mf = 0;
		while (true) {
			PriorityQueue<int[]> q = new PriorityQueue<int[]>((u, v) -> (u[1] - v[1]));
			p = new int[V];
			d = new int[V];
			Arrays.fill(p, -1);
			Arrays.fill(d, (int) 1e9);
			q.add(new int[] { s, 0 });
			p[s] = s;
			d[s] = 0;
			while (!q.isEmpty()) {
				int[] u = q.remove();
				if (u[0] == t)
					break;
				for (int v : adjList[u[0]]) {
					if (res[u[0]][v] > 0 && u[1] + cost[u[0]][v] < d[v]) {
						d[v] = u[1] + cost[u[0]][v];
						p[v] = u[0];
						q.add(new int[] { v, u[1] + cost[u[0]][v] });
					}
				}
			}
			if (p[t] == -1)
				break;
			mf += augment(t, INF);
		}
		return mf;
	}

	static int augment(int v, int flow) {
		if (v == s)
			return flow;
		flow = augment(p[v], Math.min(flow, res[p[v]][v]));
		res[p[v]][v] -= flow;
		res[v][p[v]] += flow;
		return flow;
	}

	static void add(int cur, int nxt, ArrayList<Integer> al) {
		int idx = 1;
		for (int i = 1; i < 1 << 10; i <<= 1) {
			if ((i & cur) == 0 && (i & nxt) != 0) {
				al.add(idx);
			}
			idx++;
		}
	}

	static ArrayList<Integer> solve(int n) {
		int[] match = new int[n];
		int[] matchN = new int[n];
		Arrays.fill(match, -1);
		Arrays.fill(matchN, -1);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (adjMatrix[i << 1][j << 1 | 1] == 1 && res[i << 1][j << 1 | 1] == 0) {
					match[j] = i;
					matchN[i] = j;
				}
			}
		}
		ArrayList<Integer> ans = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			if (match[i] == -1) {
				if (!ans.isEmpty()) {
					ans.add(-1);
				}
				add(0, nodes[i], ans);
				int cur = i;
				while (true) {
//					System.out.println(cur);
					if (matchN[cur] == -1)
						break;
					add(nodes[cur], nodes[matchN[cur]], ans);
					cur = matchN[cur];
				}
			}
		}
		return ans;
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int d = sc.nextInt();
		int n = sc.nextInt();
		V = 2 * n + 2;
		s = 2 * n;
		t = 2 * n + 1;
		res = new int[V][V];
		cost = new int[V][V];
		nodes = new int[n];
		adjList = new ArrayList[V];
		for (int i = 0; i < adjList.length; i++) {
			adjList[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < nodes.length; i++) {
			nodes[i] = Integer.parseInt(sc.next(), 2);
		}
		adjMatrix = new int[V][V];
		for (int i = 0; i < n; i++) {
			addEdge(s, i << 1, 0);
			addEdge(i << 1 | 1, t, 0);
			for (int j = i + 1; j < n; j++) {
				if ((nodes[i] & nodes[j]) == nodes[i]) {
					// i is submask -> edge from i to j
					addEdge(i << 1, j << 1 | 1, Integer.bitCount(nodes[j] ^ nodes[i]));
				} else if ((nodes[i] & nodes[j]) == nodes[j]) {
					addEdge(j << 1, i << 1 | 1, Integer.bitCount(nodes[j] ^ nodes[i]));
				}
			}
		}
		edmondsKarp();
//		System.out.println(Arrays.toString(match));
//		System.out.println(Arrays.toString(matchN));
		ArrayList<Integer> sol = solve(n);
		pw.println(sol.size());
		for (int x : sol) {
			if (x == -1) {
				pw.print("R ");
			} else {
				pw.print((d - x) + " ");
			}
		}
		pw.println();
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader f) {
			br = new BufferedReader(f);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}

	}

}