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.
#include <bits/stdc++.h>
using namespace std;
int inf;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T, class T2>
int chkmin(T &a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
template <class T, class T2>
int chkmax(T &a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T, class T2>
T mmin(T a, T2 b) {
  return a < b ? a : b;
}
template <class T, class T2>
T mmax(T a, T2 b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
int dcmp(T a, T b) {
  return a > b;
}
template <int *a>
int cmp_a(int first, int second) {
  return a[first] < a[second];
}
struct __INIT__ {
  __INIT__() { memset(&inf, 0x3f, sizeof(inf)); }
} __INIT___;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char first) {
  *oS++ = first;
  if (oS == oT) flush();
}
template <typename A>
inline bool read(A &first) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (first = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    first = first * 10 + (c & 15);
  first *= f;
  return 1;
}
inline bool read(char &first) {
  while ((first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)) == ' ' ||
         first == '\n' || first == '\r')
    ;
  return first != EOF;
}
inline bool read(char *first) {
  while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                                (iS == iT ? EOF : *iS++))
                             : *iS++)) == '\n' ||
         *first == ' ' || *first == '\r')
    ;
  if (*first == EOF) return 0;
  while (!(*first == '\n' || *first == ' ' || *first == '\r' || *first == EOF))
    *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                           : *iS++);
  *first = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &first, B &...second) {
  return read(first) && read(second...);
}
template <typename A>
inline bool write(A first) {
  if (!first) putc('0');
  if (first < 0) putc('-'), first = -first;
  while (first) qu[++qr] = first % 10 + '0', first /= 10;
  while (qr) putc(qu[qr--]);
  return 0;
}
inline bool write(char first) {
  putc(first);
  return 0;
}
inline bool write(const char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
inline bool write(char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A first, B... second) {
  return write(first) || write(second...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
char s[300005];
int first[300005], second[300005];
multiset<int> l1, l2, r1, r2;
int n;
vector<pair<int, int> > vt[1000005];
bool chk(int w) {
  int yl = 0, yr = inf;
  for (int i = 1; i <= n; ++i) {
    int xl = first[i] - w, xr = first[i] + w;
    chkmax(yl, xl);
    chkmin(yr, xr);
  }
  if (yl > yr) return 0;
  for (int i = yl; i <= yr; ++i) vt[i].clear();
  for (int i = 1; i <= n; ++i) {
    int xl = mmax(first[i] - w, 0), xm = first[i], xr = first[i] + w;
    if (chkmax(xm, yl)) {
      chkmin(xr, yr);
      ++xr;
      vt[xm].emplace_back(5, mmax(second[i] + w, 0));
      vt[xm].emplace_back(7, second[i] - first[i] - w);
      if (xr <= yr) {
        vt[xr].emplace_back(6, mmax(second[i] + w, 0));
        vt[xr].emplace_back(8, second[i] - first[i] - w);
      }
      continue;
    }
    if (chkmin(xm, yr)) {
      chkmax(xl, yl);
      ++xm;
      vt[xl].emplace_back(1, mmax(second[i] - w, 0));
      vt[xl].emplace_back(3, second[i] - first[i] + w);
      continue;
    }
    chkmax(xl, yl);
    chkmin(xr, yr);
    if (xl < xm) {
      vt[xl].emplace_back(1, mmax(second[i] - w, 0));
      vt[xm].emplace_back(2, mmax(second[i] - w, 0));
      vt[xl].emplace_back(3, second[i] - first[i] + w);
      vt[xm].emplace_back(4, second[i] - first[i] + w);
    }
    ++xr;
    vt[xm].emplace_back(5, mmax(second[i] + w, 0));
    vt[xm].emplace_back(7, second[i] - first[i] - w);
    if (xr <= yr) {
      vt[xr].emplace_back(6, mmax(second[i] + w, 0));
      vt[xr].emplace_back(8, second[i] - first[i] - w);
    }
  }
  l1.clear();
  l2.clear();
  r1.clear();
  r2.clear();
  for (int i = yl; i <= yr; ++i) {
    for (auto p : vt[i]) {
      int first = p.second;
      switch (p.first) {
        case 1:
          l1.insert(first);
          break;
        case 2:
          l1.erase(l1.lower_bound(first));
          break;
        case 3:
          r2.insert(first);
          break;
        case 4:
          r2.erase(r2.lower_bound(first));
          break;
        case 5:
          r1.insert(first);
          break;
        case 6:
          r1.erase(r1.lower_bound(first));
          break;
        case 7:
          l2.insert(first);
          break;
        case 8:
          l2.erase(l2.lower_bound(first));
          break;
      }
    }
    if (i >= yl) {
      int l = mmax(l1.empty() ? -1 : *l1.rbegin(),
                   l2.empty() ? -inf : *l2.rbegin() + i);
      if (i == 0) chkmax(l, 1);
      int r = mmin(r1.empty() ? inf : *r1.begin(),
                   r2.empty() ? inf : *r2.begin() + i);
      if (l <= r) return 1;
    }
  }
  return 0;
}
pair<int, int> get(int w) {
  int yl = 0, yr = inf;
  for (int i = 1; i <= n; ++i) {
    int xl = first[i] - w, xr = first[i] + w;
    chkmax(yl, xl);
    chkmin(yr, xr);
  }
  for (int i = yl; i <= yr; ++i) vt[i].clear();
  for (int i = 1; i <= n; ++i) {
    int xl = mmax(first[i] - w, 0), xm = first[i], xr = first[i] + w;
    if (chkmax(xm, yl)) {
      chkmin(xr, yr);
      ++xr;
      vt[xm].emplace_back(5, mmax(second[i] + w, 0));
      vt[xm].emplace_back(7, second[i] - first[i] - w);
      if (xr <= yr) {
        vt[xr].emplace_back(6, mmax(second[i] + w, 0));
        vt[xr].emplace_back(8, second[i] - first[i] - w);
      }
      continue;
    }
    if (chkmin(xm, yr)) {
      chkmax(xl, yl);
      ++xm;
      vt[xl].emplace_back(1, mmax(second[i] - w, 0));
      vt[xl].emplace_back(3, second[i] - first[i] + w);
      continue;
    }
    chkmax(xl, yl);
    chkmin(xr, yr);
    if (xl < xm) {
      vt[xl].emplace_back(1, mmax(second[i] - w, 0));
      vt[xm].emplace_back(2, mmax(second[i] - w, 0));
      vt[xl].emplace_back(3, second[i] - first[i] + w);
      vt[xm].emplace_back(4, second[i] - first[i] + w);
    }
    ++xr;
    vt[xm].emplace_back(5, mmax(second[i] + w, 0));
    vt[xm].emplace_back(7, second[i] - first[i] - w);
    if (xr <= yr) {
      vt[xr].emplace_back(6, mmax(second[i] + w, 0));
      vt[xr].emplace_back(8, second[i] - first[i] - w);
    }
  }
  l1.clear();
  l2.clear();
  r1.clear();
  r2.clear();
  for (int i = yl; i <= yr; ++i) {
    for (auto p : vt[i]) {
      int first = p.second;
      switch (p.first) {
        case 1:
          l1.insert(first);
          break;
        case 2:
          l1.erase(l1.lower_bound(first));
          break;
        case 3:
          r2.insert(first);
          break;
        case 4:
          r2.erase(r2.lower_bound(first));
          break;
        case 5:
          r1.insert(first);
          break;
        case 6:
          r1.erase(r1.lower_bound(first));
          break;
        case 7:
          l2.insert(first);
          break;
        case 8:
          l2.erase(l2.lower_bound(first));
          break;
      }
    }
    if (i >= yl) {
      int l = mmax(l1.empty() ? 0 : *l1.rbegin(),
                   l2.empty() ? -inf : *l2.rbegin() + i);
      int r = mmin(r1.empty() ? inf : *r1.begin(),
                   r2.empty() ? inf : *r2.begin() + i);
      if (i == 0) chkmax(l, 1);
      if (l <= r) return make_pair(i, l);
    }
  }
  return make_pair(0, 0);
}
signed main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(s);
    int l = strlen(s);
    for (int j = 0; j < l; ++j) {
      first[i] += s[j] == 'B';
    }
    second[i] = l - first[i];
  }
  int l = 0, r = 500000;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (chk(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  write(r + 1, '\n');
  pair<int, int> w = get(r + 1);
  for (int i = 0; i < w.first; ++i) putc('B');
  for (int i = 0; i < w.second; ++i) putc('N');
  putc('\n');
  return 0;
}
