#include using namespace std; using ll = long long; struct UnionFind{ vector par, rank, siz; UnionFind(int n): par(n, -1), rank(n, 0), siz(n, 1){} // x の根を求める int root(int x){ if(par[x] == -1) return x; else return par[x] = root(par[x]); } // x と y が連結か bool same(int x, int y){ return root(x) == root(y); } // x と y を結ぶ bool merge(int x, int y){ int rx = root(x), ry = root(y); if(rx == ry) return false; if(rank[rx] < rank[ry]) swap(rx, ry); par[ry] = rx; if(rank[rx] == rank[ry]) ++rank[rx]; siz[rx] += siz[ry]; return true; } // x の連結成分の個数 int size(int x){ return siz[root(x)]; } }; void solve(){ int N; cin >> N; UnionFind uf(16); vector ok(16, false); vector A(N); for(int i = 0; i < N; ++i){ cin >> A[i]; int c = -1; for(int j = 0; j < 16; ++j){ if((A[i] >> j) & 1){ ok[j] = true; if(c == -1){ c = j; }else{ uf.merge(c, j); } } } } int B = 0, W = 0; int g = -1; vector k(15, 0); for(int i = 15; i >= 0; --i){ if(ok[i]){ if(g == -1){ B += (1 << i); g = i; k[i] = 1; }else if(uf.same(g, i)){ B += (1 << i); k[i] = 1; }else{ W += (1 << i); } } } cout << B * W << "\n"; if(B * W == 0){ for(int i = 0; i < N; ++i) cout << "B"; cout << "\n"; }else{ for(int i = 0; i < N; ++i){ if((A[i] >> g) & 1) cout << "B"; else cout << "W"; } cout << "\n"; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(10) << fixed; int T; T = 1; //cin >> T; for(;T--;) solve(); }