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;
template <class C>
void mini(C& a, C b) {
  a = min(a, b);
}
template <class C>
void maxi(C& a, C b) {
  a = max(a, b);
}
int m;
void parsear(string& s, string& r, vector<vector<int>>& b,
             vector<vector<int>>& e) {
  map<char, int> trad;
  for (int i = 0; i < s.size(); i++) trad[s[i]] = trad.size() - 1;
  int i = 0;
  while (i < r.size()) {
    b.push_back({});
    while (r[i] != '>') {
      b.back().push_back(trad[r[i]]);
      i++;
    }
    i++;
    e.push_back({});
    while (i < r.size() and r[i] != '|') {
      e.back().push_back(trad[r[i]]);
      i++;
    }
    i++;
  }
}
int enciende[64], apaga[64];
vector<vector<vector<int>>> armarAFND(vector<vector<int>>& b,
                                      vector<vector<int>>& e) {
  int n = 1;
  for (int i = 0; i < b.size(); i++) n += b[i].size();
  for (int i = 0; i < e.size(); i++) n += e[i].size();
  vector<vector<vector<int>>> afnd(n, vector<vector<int>>(m));
  int state = 0;
  for (int c = 0; c < m; c++) afnd[0][c].push_back(0);
  for (int i = 0; i < b.size(); i++) {
    for (int j = 0; j < b[i].size(); j++) {
      state++;
      if (j == 0)
        afnd[0][b[i][j]].push_back(state);
      else
        afnd[state - 1][b[i][j]].push_back(state);
    }
    enciende[state] = i;
  }
  for (int i = 0; i < e.size(); i++) {
    for (int j = 0; j < e[i].size(); j++) {
      state++;
      if (j == 0)
        afnd[0][e[i][j]].push_back(state);
      else
        afnd[state - 1][e[i][j]].push_back(state);
    }
    apaga[state] = i;
  }
  return afnd;
}
long long transicion(vector<vector<vector<int>>>& afnd, long long state,
                     int c) {
  long long statep = 0;
  for (int i = 0; i < afnd.size(); i++)
    if (state & (1ll << i))
      for (int j = 0; j < afnd[i][c].size(); j++)
        statep |= (1 << (afnd[i][c][j]));
  return statep;
}
long long nuevoBit(long long statep, long long bit) {
  for (int i = 0; i < 64; i++) {
    if ((statep & (1ll << i)) == 0) continue;
    if (enciende[i] != -1 and ((bit & (1 << enciende[i])) == 0))
      bit += (1 << (enciende[i]));
    if (apaga[i] != -1 and (bit & (1 << (apaga[i]))) != 0)
      bit -= (1 << (apaga[i]));
  }
  return bit;
}
map<long long, vector<vector<pair<long long, long long>>>> armarTransiciones(
    vector<vector<vector<int>>>& afnd, int rules) {
  map<long long, vector<vector<pair<long long, long long>>>> M;
  queue<long long> q;
  q.push(1);
  long long statep, bitp;
  while (!q.empty()) {
    long long state = q.front();
    q.pop();
    if (M.count(state)) continue;
    M[state] = vector<vector<pair<long long, long long>>>(
        1 << rules, vector<pair<long long, long long>>(m));
    for (int bit = 0; bit < (1 << rules); bit++) {
      for (int c = 0; c < m; c++) {
        statep = transicion(afnd, state, c);
        bitp = nuevoBit(statep, bit);
        M[state][bit][c] = make_pair(statep, bitp);
      }
    }
    for (int c = 0; c < m; c++) q.push(transicion(afnd, state, c));
  }
  return M;
}
void h() {
  memset(enciende, -1, sizeof(enciende));
  memset(apaga, -1, sizeof(apaga));
  int k;
  string s, r;
  cin >> k >> s >> r;
  m = s.size();
  vector<vector<int>> b, e;
  parsear(s, r, b, e);
  vector<vector<vector<int>>> afnd = armarAFND(b, e);
  map<long long, vector<vector<pair<long long, long long>>>> M =
      armarTransiciones(afnd, b.size());
  vector<map<long long, vector<long long>>> dp(2);
  for (int i = 0; i < 2; i++) {
    for (auto it = M.begin(); it != M.end(); ++it) {
      long long state = it->first;
      dp[i][state] = vector<long long>(1 << b.size());
    }
  }
  dp[0][1][0] = 1;
  long long statep, bitp;
  for (int i = 0; i < k; i++) {
    for (auto it = M.begin(); it != M.end(); ++it) {
      long long state = it->first;
      for (int bit = 0; bit < (1 << b.size()); bit++)
        dp[(i + 1) % 2][state][bit] = 0;
    }
    for (auto it = M.begin(); it != M.end(); ++it) {
      long long state = it->first;
      for (int bit = 0; bit < (1 << b.size()); bit++) {
        for (int c = 0; c < m; c++) {
          tie(statep, bitp) = M[state][bit][c];
          dp[(i + 1) % 2][statep][bitp] += dp[i % 2][state][bit];
          dp[(i + 1) % 2][statep][bitp] %= 10000000;
        }
      }
    }
  }
  long long res = 0;
  for (auto it = M.begin(); it != M.end(); ++it) {
    long long state = it->first;
    res += dp[k % 2][state][0];
    res %= 10000000;
  }
  cout << res << '\n';
}
void a() {
  int n, d;
  long long m;
  cin >> n >> d >> m;
  long long aux;
  vector<long long> menores, mayores;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (aux <= m)
      menores.push_back(aux);
    else
      mayores.push_back(aux);
  }
  sort(menores.begin(), menores.end());
  reverse(menores.begin(), menores.end());
  sort(mayores.begin(), mayores.end());
  long long res = 0;
  if (mayores.size() == 0) {
    for (int i = 0; i < n; i++) res += menores[i];
    cout << res << '\n';
    return;
  }
  res += mayores.back();
  mayores.pop_back();
  reverse(mayores.begin(), mayores.end());
  long long ress = 0;
  for (int i = 0; i < menores.size(); i++) res += menores[i];
  maxi(ress, res);
  int i = menores.size();
  int j = 0;
  while (j < mayores.size() and i + (j + 1) * (d + 1) <= n - 1) {
    res += mayores[j];
    j++;
  }
  maxi(ress, res);
  while (i > 0) {
    i--;
    res -= menores[i];
    while (j < mayores.size() and i + (j + 1) * (d + 1) <= n - 1) {
      res += mayores[j];
      j++;
    }
    maxi(ress, res);
  }
  cout << ress << '\n';
}
long long distancia(long long a1, long long b1, long long a2, long long b2) {
  if ((a1 - a2) * (b1 - b2) < 0) return abs(a1 - a2) + abs(b1 - b2);
  return max(abs(a1 - a2), abs(b1 - b2));
}
int n;
long long distanciaMaxima(long long x, long long y, vector<long long>& a,
                          vector<long long>& b) {
  long long res = 0;
  for (int i = 0; i < n; i++) maxi(res, distancia(x, y, a[i], b[i]));
  return res;
}
void minimizar(long long& x, long long& y, vector<long long>& a,
               vector<long long>& b, long long salto) {
  while (true) {
    long long d = distanciaMaxima(x, y, a, b);
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        if (x + i * salto >= 0 and y + j * salto >= 0 and
            distanciaMaxima(x + i * salto, y + j * salto, a, b) < d) {
          x += i * salto;
          y += j * salto;
          goto end;
        }
      }
    }
    break;
  end:;
  }
}
void c() {
  cin >> n;
  string s;
  vector<long long> a(n);
  vector<long long> b(n);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == 'B')
        a[i]++;
      else
        b[i]++;
    }
  }
  long long x = 1;
  long long y = 1;
  long long salto = 100000;
  while (salto > 0) {
    minimizar(x, y, a, b, salto);
    salto /= 2;
  }
  cout << distanciaMaxima(x, y, a, b) << '\n';
  for (int i = 0; i < x; i++) cout << 'B';
  for (int i = 0; i < y; i++) cout << 'N';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  c();
  return 0;
}
