from collections import deque N = int(input()) A = list(map(int, input().split())) que = deque([(0, 0, 0, "")]) # (w, b, i, s) visited = set() visited.add((0, 0, 0)) # (w, b, i) while que: if que[0][2] == N: # 末端はそのまま、あとで全部調べる break w,b,i,s = que.popleft() a = A[i] # 黒に割り当て if (w & a) == 0: w2, b2, i2, s2 = w, b | a, i + 1, s + "B" key = (w2, b2, i2) if key not in visited: visited.add(key) que.append((w2, b2, i2, s2)) # 白に割り当て if (b & a) == 0: w2, b2, i2, s2 = w | a, b, i + 1, s + "W" key = (w2, b2, i2) if key not in visited: visited.add(key) que.append((w2, b2, i2, s2)) # N個割り当てたものの中で最大値 m = 0 ans = "" # i==Nのもののみ考慮 for w, b, i, s in que: if w * b > m: m = w * b ans = s print(m) print(ans)