#include #include using namespace std; using namespace atcoder; using ll = long long; using mint=modint998244353; using ld = long double; const ll infl = 1LL << 60; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const vector dx = {1, 0, -1, 0}; const vector dy = {0, 1, 0, -1}; template using vc = vector; template using vvc = vc>; template using vvvc = vc>; using vi = vc; using vvi = vvc; using vl = vc; using vvl = vvc; using vvvl = vvc; using vvvvl = vvc; using vs = vc; using vvs = vvc; using P = pair; #define nrep(i,n) for (ll i = 0; i < (n); ++i) #define nfor(i,s,n) for(ll i=s;i using pq = priority_queue>;//★大きい順に取り出す コスト,頂点 bfs系で使う 小さい順じゃないですABC305E template using pq_g = priority_queue, greater>;//小さい順に取り出す ダイクストラ法で使う #define cout(n) cout< 0) { s += (n % 2) + '0'; n /= 2; } reverse(s.begin(), s.end()); while(s.size() < k) s = '0' + s; return s; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cin >> N; vl a(N); vc s(N); nrep(i, N){ cin >> a[i]; } vc> v; nrep(bits, 1 << 12) { string tmp_s = ""; ll tmp_w = 0; ll tmp_b = 0; nrep(i, N) { bool w = false; bool b = false; nrep(j, 12) { if (a[i] & (1 << j) && bits & (1 << j)) { w = true; } else if (a[i] & (1 << j) && !(bits & (1 << j))) { b = true; } } if (w && b) goto skip; if(w) { tmp_s += "W"; tmp_w |= a[i]; } else if(b) { tmp_s += "B"; tmp_b |= a[i]; } else { tmp_s += "W"; } } v.push_back({tmp_w * tmp_b, tmp_s}); skip:; } // nrep(i, v.size()) { // cout << v[i].first << " " << v[i].second << endl; // } sort(v.rbegin(), v.rend()); cout << v[0].first << endl; cout << v[0].second << endl; }