Boboniu defines BN-string as a string s of characters 'B' and 'N'.

You can perform the following operations on the BN-string s:

  * Remove a character of s. 
  * Remove a substring "BN" or "NB" of s. 
  * Add a character 'B' or 'N' to the end of s. 
  * Add a string "BN" or "NB" to the end of s. 



Note that a string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

Boboniu thinks that BN-strings s and t are similar if and only if:

  * |s|=|t|. 
  * There exists a permutation p_1, p_2, …, p_{|s|} such that for all i (1≤ i≤ |s|), s_{p_i}=t_i. 



Boboniu also defines dist(s,t), the distance between s and t, as the minimum number of operations that makes s similar to t.

Now Boboniu gives you n non-empty BN-strings s_1,s_2,…, s_n and asks you to find a non-empty BN-string t such that the maximum distance to string s is minimized, i.e. you need to minimize max_{i=1}^n dist(s_i,t).

Input

The first line contains a single integer n (1≤ n≤ 3⋅ 10^5).

Each of the next n lines contains a string s_i (1≤ |s_i| ≤ 5⋅ 10^5). It is guaranteed that s_i only contains 'B' and 'N'. The sum of |s_i| does not exceed 5⋅ 10^5.

Output

In the first line, print the minimum max_{i=1}^n dist(s_i,t).

In the second line, print the suitable t.

If there are several possible t's, you can print any.

Examples

Input


3
B
N
BN


Output


1
BN


Input


10
N
BBBBBB
BNNNBBNBB
NNNNBNBNNBNNNBBN
NBNBN
NNNNNN
BNBNBNBBBBNNNNBBBBNNBBNBNBBNBBBBBBBB
NNNNBN
NBBBBBBBB
NNNNNN


Output


12
BBBBBBBBBBBBNNNNNNNNNNNN


Input


8
NNN
NNN
BBNNBBBN
NNNBNN
B
NNN
NNNNBNN
NNNNNNNNNNNNNNNBNNNNNNNBNB


Output


12
BBBBNNNNNNNNNNNN


Input


3
BNNNBNNNNBNBBNNNBBNNNNBBBBNNBBBBBBNBBBBBNBBBNNBBBNBNBBBN
BBBNBBBBNNNNNBBNBBBNNNBB
BBBBBBBBBBBBBBNBBBBBNBBBBBNBBBBNB


Output


12
BBBBBBBBBBBBBBBBBBBBBBBBBBNNNNNNNNNNNN

Note

In the first example dist(B,BN)=dist(N,BN)=1, dist(BN,BN)=0. So the maximum distance is 1.
//package round664;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni();
		int[][] co = new int[n][];
		Set<Long> set = new HashSet<>();
		int p = 0;
		for(int i = 0;i < n;i++){
			char[] s = ns().toCharArray();
			int x = 0, y = 0;
			for(char c : s){
				if(c == 'N'){
					x++;
				}else{
					y++;
				}
			}
			long code = (long)x<<32|y;
			if(set.add(code)){
				co[p++] = new int[]{x, y};
			}
		}
		co = Arrays.copyOf(co, p);
		Arrays.sort(co, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				return a[0] - b[0];
			}
		});
		/*
		ok(co, 2);
		if(true)return;
		*/
		
		int low = -1, high = 500005;
		while(high - low > 1){
			int h = high+low>>1;
			if(ok(co, h)){
				high = h;
			}else{
				low = h;
			}
		}
		// 1 2
		// 4 1
		// 4 4
		ok(co, high);
		assert d(highx, highy, co) <= high;
		out.println(high);
		for(int i = 0;i < highx;i++){
			out.print("N");
		}
		for(int i = 0;i < highy;i++){
			out.print("B");
		}
		out.println();
	}
	
	int d(int x, int y, int[][] co)
	{
		int d = 0;
		for(int[] u : co){
			if(u[0] <= x && u[1] >= y){
				d = Math.max(d, Math.abs(x-u[0]) + Math.abs(y-u[1]));
			}else if(x <= u[0] && y >= u[1]){
				d = Math.max(d, Math.abs(x-u[0]) + Math.abs(y-u[1]));
			}else{
				d = Math.max(d, Math.max(Math.abs(x-u[0]), Math.abs(y-u[1])));
			}
		}
		return d;
	}
	
	int highx;
	int highy;
	
	boolean ok(int[][] co, int h)
	{
		int p = 0;
		int n = co.length;
		int[][] es = new int[3*n][];
		for(int i = 0;i < n;i++){
			es[p++] = new int[]{co[i][0]-h, i, 0};
			es[p++] = new int[]{co[i][0], i, 1};
			es[p++] = new int[]{co[i][0]+h, i, 2};
		}
		Arrays.sort(es, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				if(a[0] - b[0] != 0)return a[0] - b[0];
				return a[2] - b[2];
			}
		});
//		tr(h, es);
		
		MinHeap infl = new MinHeap(n);
		MinHeap supl = new MinHeap(n);
		MinHeap infr = new MinHeap(n);
		MinHeap supr = new MinHeap(n);
		int nin = 0;
		int prex = -2;
		for(int[] e : es){
			/*
			if(nin == n && prex < e[0]){
				int x = e[0]-1;
				int inf = x < 0 ? Integer.MAX_VALUE / 3 : x == 0 ? 1 : 0;
				if(Math.max(inf, Math.max(-infl.min(), (-infr.min() + x))) <= Math.min(supl.min() + x, supr.min())){
					highx = x;
					highy = Math.max(inf, Math.max(-infl.min(), (-infr.min() + x)));
					return true;
				}
			
			}
			*/
			if(nin == n){
				int x = e[0];
				int inf = x < 0 ? Integer.MAX_VALUE / 3 : x == 0 ? 1 : 0;
				if(Math.max(inf, Math.max(-infl.min(), (-infr.min() + x))) <= Math.min(supl.min() + x, supr.min())){
					highx = x;
					highy = Math.max(inf, Math.max(-infl.min(), (-infr.min() + x)));
					return true;
				}
			}
			if(e[2] == 0){
				nin++;
				int i = e[1];
				infl.add(i, -(co[i][1]-h));
				supl.add(i, co[i][1]-co[i][0]+h);
			}else if(e[2] == 1){
				int i = e[1];
				infl.remove(i);
				supl.remove(i);
				supr.add(i, co[i][1]+h);
				infr.add(i, -(co[i][1]-co[i][0]-h));
			}else{
				int i = e[1];
				infr.remove(i);
				supr.remove(i);
				nin--;
			}
			if(nin == n){
				int x = e[0];
				int inf = x < 0 ? Integer.MAX_VALUE / 3 : x == 0 ? 1 : 0;
//				tr(infl.min(), infr.min() + x);
//				tr(x, Math.max(inf, Math.max(-infl.min(), (-infr.min() + x))), Math.min(supl.min() + x, supr.min()));
				if(Math.max(inf, Math.max(-infl.min(), (-infr.min() + x))) <= Math.min(supl.min() + x, supr.min())){
					highx = x;
					highy = Math.max(inf, Math.max(-infl.min(), (-infr.min() + x)));
					return true;
				}
			}
			prex = e[0];
		}
		return false;
	}
	
	public static class MinHeap {
		public int[] a;
		public int[] map;
		public int[] imap;
		public int n;
		public int pos;
		public static int INF = Integer.MAX_VALUE / 10;
		
		public MinHeap(int m)
		{
			n = m+2;
			a = new int[n];
			map = new int[n];
			imap = new int[n];
			Arrays.fill(a, INF);
			Arrays.fill(map, -1);
			Arrays.fill(imap, -1);
			pos = 1;
		}
		
		public int add(int ind, int x)
		{
			int ret = imap[ind];
			if(imap[ind] < 0){
				a[pos] = x; map[pos] = ind; imap[ind] = pos;
				pos++;
				up(pos-1);
			}
			return ret != -1 ? a[ret] : x;
		}
		
		public int update(int ind, int x)
		{
			int ret = imap[ind];
			if(imap[ind] < 0){
				a[pos] = x; map[pos] = ind; imap[ind] = pos;
				pos++;
				up(pos-1);
			}else{
				int o = a[ret];
				a[ret] = x;
				up(ret);
				down(ret);
//				if(a[ret] > o){
//					up(ret);
//				}else{
//					down(ret);
//				}
			}
			return x;
		}
		
		public int remove(int ind)
		{
			if(pos == 1)return INF;
			if(imap[ind] == -1)return INF;
			
			pos--;
			int rem = imap[ind];
			int ret = a[rem];
			map[rem] = map[pos];
			imap[map[pos]] = rem;
			imap[ind] = -1;
			a[rem] = a[pos];
			a[pos] = INF;
			map[pos] = -1;
			
			up(rem);
			down(rem);
			return ret;
		}
		
		public int min() { return a[1]; }
		public int argmin() { return map[1]; }
		public int size() {	return pos-1; }
		
		private void up(int cur)
		{
			for(int c = cur, p = c>>>1;p >= 1 && a[p] > a[c];c>>>=1, p>>>=1){
				int d = a[p]; a[p] = a[c]; a[c] = d;
				int e = imap[map[p]]; imap[map[p]] = imap[map[c]]; imap[map[c]] = e;
				e = map[p]; map[p] = map[c]; map[c] = e;
			}
		}
		
		private void down(int cur)
		{
			for(int c = cur;2*c < pos;){
				int b = a[2*c] < a[2*c+1] ? 2*c : 2*c+1;
				if(a[b] < a[c]){
					int d = a[c]; a[c] = a[b]; a[b] = d;
					int e = imap[map[c]]; imap[map[c]] = imap[map[b]]; imap[map[b]] = e;
					e = map[c]; map[c] = map[b]; map[b] = e;
					c = b;
				}else{
					break;
				}
			}
		}
	}

	
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new C().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
