Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. 

Akhil has many balls of white and black colors. One day, he was playing with them. During the play, he arranged the balls into two rows both consisting of N number of balls. These two rows of balls are given to you in the form of strings X, Y. Both these string consist of 'W' and 'B', where 'W' denotes a white colored ball and 'B' a black colored.

Other than these two rows of balls, Akhil has an infinite supply of extra balls of each color. he wants to create another row of N balls, Z in such a way that the sum of hamming distance between X and Z, and hamming distance between Y and Z is maximized.

Hamming Distance between two strings X and Y is defined as the number of positions where the color of balls in row X differs from the row Y ball at that position. e.g. hamming distance between "WBB", "BWB" is 2, as at position 1 and 2, corresponding colors in the two strings differ..

As there can be multiple such arrangements of row Z, Akhil wants you to find the lexicographically smallest arrangement which will maximize the above value. 

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows:
First line of each test case will contain a string X denoting the arrangement of balls in first row
Second line will contain the string Y denoting the arrangement of balls in second row.

------ Output ------ 

For each test case, output a single line containing the string of length N denoting the arrangement of colors of the balls belonging to row Z.

------ Constraints ------ 

$1 ≤ T ≤ 3$

------ Subtasks ------ 

Subtask #1 (10 points) : 1 ≤ N ≤ 16
Subtask #2 (20 points) : 1 ≤ N ≤ 10^{3}
Subtask #3 (70 points) : 1 ≤ N ≤ 10^{5}

----- Sample Input 1 ------ 
1
WBWB
WBBB
----- Sample Output 1 ------ 
BWBW
----- explanation 1 ------ 
Example case 1. As we know, Hamming Distance(WBWB, BWBW) + Hamming Distance(WBBB, BWBW) = 4 + 3 = 7.
You can try any other value for string Z, it will never exceed 6.

Source: codechef | Difficulty: EASY
Tags: Constructive algorithms

String algorithms

Greedy algorithms

Mathematics

Data structures

Ad-hoc


Solutions:
T = int(input())
for i in range(T):
	X = input()
	Y = input()
	Z = ''
	for j in range(len(X)):
		if X[j] == 'B' and Y[j] == 'B':
			Z += 'W'
		else:
			Z += 'B'
	print(Z)


for t in range(int(input())):
	x = input()
	y = input()
	z = ''
	for i in range(len(x)):
		if x[i] == 'W' and y[i] == 'W':
			z = z + 'B'
		if x[i] == 'B' and y[i] == 'B':
			z = z + 'W'
		if x[i] == 'W' and y[i] == 'B':
			z = z + 'B'
		if x[i] == 'B' and y[i] == 'W':
			z = z + 'B'
	print(z)


for _ in range(int(input())):
	X = input().upper()
	Y = input().upper()
	Z = ''
	for i in range(len(X)):
		if X[i] == 'B' and Y[i] == 'B':
			Z += 'W'
		else:
			Z += 'B'
	print(Z)


for i in range(int(input())):
	A = input().upper()
	B = input().upper()
	C = ''
	for i in range(len(A)):
		if A[i] == 'B' and B[i] == 'B':
			C += 'W'
		elif A[i] == 'W' and B[i] == 'W':
			C += 'B'
		else:
			C += 'B'
	print(C)


for _ in range(int(input())):
	a = input()
	b = input()
	p = ''
	for i in range(len(a)):
		if a[i] == b[i]:
			if a[i] == 'B':
				p += 'W'
			else:
				p += 'B'
		else:
			p += 'B'
	print(p)


for _ in range(int(input())):
	x = input()
	y = input()
	s = ''
	for i in range(len(x)):
		if x[i] == y[i]:
			if x[i] == 'W':
				s += 'B'
			else:
				s += 'W'
		else:
			s += 'B'
	print(s)


for _ in range(int(input())):
	x = input()
	y = input()
	n = len(x)
	out = ''
	for i in range(n):
		if x[i] == 'W' and y[i] == 'W':
			out += 'B'
		elif x[i] == 'B' and y[i] == 'B':
			out += 'W'
		else:
			out += 'B'
	print(out)


t = int(input())
while t:
	x = input()
	y = input()
	stri = ''
	for i in range(len(x)):
		if x[i] == y[i]:
			if x[i] == 'W':
				stri += 'B'
			else:
				stri += 'W'
		else:
			stri += min(x[i], y[i])
	print(stri)
	t -= 1


t = int(input(''))
if 1 <= t <= 3:
	for _ in range(t):
		x = input('')
		y = input('')
		n = len(x)
		s = ''
		for i in range(n):
			if x[i] == y[i]:
				if x[i] == 'W':
					s += 'B'
				else:
					s += 'W'
			else:
				s += 'B'
		print(s)


n = int(input())
for items in range(0, n):
	x = input()
	y = input()
	z = ''
	for j in range(len(x)):
		if x[j] == 'B' and y[j] == 'B':
			z += 'W'
		else:
			z += 'B'
	print(z)


for _ in range(int(input())):
	X = input().strip()
	Y = input().strip()
	Z = ''
	choice = {'B', 'W'}
	for (x, y) in zip(X, Y):
		if x == y:
			Z += (choice - {x}).pop()
		else:
			Z += 'B'
	print(Z)


for i in range(int(input())):
	x = input()
	y = input()
	a = ''
	for i in range(len(x)):
		if x[i] == 'W' and y[i] == 'W':
			a += 'B'
		elif x[i] == 'B' and y[i] == 'B':
			a += 'W'
		else:
			a += 'B'
	print(a)


tests = int(input())
for i in range(tests):
	x = input()
	y = input()
	ans = ''
	for j in range(len(x)):
		if x[j] == y[j]:
			if x[j] == 'B':
				ans += 'W'
			else:
				ans += 'B'
		else:
			ans += 'B'
	print(ans)


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	n = len(s1)
	for i in range(n):
		if s1[i] == s2[i]:
			if s1[i] == 'W':
				print('B', end='')
			else:
				print('W', end='')
		else:
			print('B', end='')
	print()


for _ in range(int(input())):
	x = input()
	y = input()
	n = len(x)
	l1 = []
	for i in range(n):
		if x[i] == y[i]:
			if x[i] == 'W':
				l1.append('B')
			else:
				l1.append('W')
		else:
			l1.append('B')
	print(''.join(l1))


for _ in range(int(input())):
	a = input()
	b = input()
	c = []
	for i in range(len(a)):
		if a[i] == b[i] and a[i] == 'B':
			c.append('W')
		else:
			c.append('B')
	print(''.join(c))


for _ in range(int(input())):
	x = input()
	y = input()
	z = ''
	for i in range(len(x)):
		if x[i] == y[i] == 'W':
			z += 'B'
		elif x[i] == y[i] == 'B':
			z += 'W'
		else:
			z += 'B'
	print(z)


def func(a):
	if x[a] == y[a]:
		return 'W' if x[a] == 'B' else 'B'
	else:
		return 'B'
for _ in range(int(input())):
	x = input()
	y = input()
	l = ''.join(map(func, range(len(x))))
	print(l)


for _ in range(int(input())):
	l = input()
	m = input()
	for i in range(len(l)):
		if l[i] == m[i] and m[i] == 'B':
			print('W', end='')
		elif l[i] == m[i] and m[i] == 'W':
			print('B', end='')
		else:
			print('B', end='')
	print()


for _ in range(int(input())):
	x = input()
	y = input()
	n = len(x)
	ans = ''
	for i in range(n):
		if x[i] == y[i]:
			if x[i] == 'B':
				ans += 'W'
			else:
				ans += 'B'
		else:
			ans += 'B'
	print(ans)


for t in range(int(input())):
	a = input()
	b = input()
	c = ''
	for i in range(len(a)):
		if a[i] == 'W' and b[i] == 'W':
			c = c + 'B'
		if a[i] == 'B' and b[i] == 'B':
			c = c + 'W'
		if a[i] == 'W' and b[i] == 'B':
			c = c + 'B'
		if a[i] == 'B' and b[i] == 'W':
			c = c + 'B'
	print(c)


t = int(input())
for _ in range(t):
	str1 = input()
	lst1 = list(str1[::1])
	str2 = input()
	lst2 = list(str2[::1])
	res_str = ''
	for i in range(len(lst1)):
		if lst1[i] == lst2[i]:
			if lst1[i] == 'B':
				res_str += 'W'
			else:
				res_str += 'B'
		else:
			res_str += 'B'
	print(res_str)


testcases = int(input())
for i in range(testcases):
	s1 = input()
	s2 = input()
	sol = ''
	for i in range(len(s1)):
		if s1[i] == 'W' and s2[i] == 'W':
			sol = sol + 'B'
		elif s1[i] == 'B' and s2[i] == 'B':
			sol = sol + 'W'
		elif s1[i] == 'B' and s2[i] == 'W':
			sol = sol + 'B'
		elif s1[i] == 'W' and s2[i] == 'B':
			sol = sol + 'B'
	print(sol)


t = int(input())
for i in range(t):
	x = input()
	y = input()
	n = len(x)
	s = ''
	for i in range(n):
		if x[i] == 'W' and y[i] == 'W':
			s = s + 'B'
		elif x[i] == 'B' and y[i] == 'B':
			s = s + 'W'
		else:
			s = s + 'B'
	print(s)


t = int(input())
for i in range(t):
	x = input()
	y = input()
	ans = ''
	for i in range(len(x)):
		if x[i] == y[i]:
			if x[i] == 'B':
				ans += 'W'
			else:
				ans += 'B'
		else:
			ans += 'B'
	print(ans)


def maxhamming(st1, st2):
	z = ''
	for i in range(len(st1)):
		if st1[i] == st2[i]:
			if st1[i] == 'W':
				z += 'B'
			else:
				z += 'W'
		else:
			z += 'B'
	return z
for tc in range(int(input())):
	x = input()
	y = input()
	print(maxhamming(x, y))


for i in range(int(input())):
	x = input().upper()
	y = input().upper()
	Z = ''
	for i in range(len(x)):
		if x[i] == 'B' and y[i] == 'B':
			Z += 'W'
		else:
			Z += 'B'
	print(Z)


listk = []
for _ in range(int(input())):
	finli = ''
	li1 = input()
	li2 = input()
	for ele in range(len(li1)):
		if li2[ele] == 'W' and li1[ele] == 'W':
			finli = finli + 'B'
		if li2[ele] == 'B' and li1[ele] == 'W':
			finli = finli + 'B'
		if li2[ele] == 'W' and li1[ele] == 'B':
			finli = finli + 'B'
		if li2[ele] == 'B' and li1[ele] == 'B':
			finli = finli + 'W'
	listk.append(finli)
for ele in listk:
	print(ele)


t = int(input())
for i in range(t):
	x = input()
	y = input()
	z = []
	for i in range(len(x)):
		if x[i] == y[i] and x[i] == 'B':
			z.append('W')
		else:
			z.append('B')
	print(''.join(z))


for i in range(int(input())):
	x = input()
	y = input()
	fi = ''
	k = 0
	while k < len(x):
		if x[k] == 'W':
			if y[k] == 'W':
				fi += 'B'
			else:
				fi += 'B'
		elif y[k] == 'W':
			fi += 'B'
		else:
			fi += 'W'
		k += 1
	print(fi)


from collections import Counter, UserString
from math import log2
mod = lambda n: int(n % (10 ** 9 + 7))
_fc = [1]
for i in range(1, 1000001):
	_fc.append(i * _fc[i - 1])
	_fc[i] = mod(_fc[i])

def fact(n):
	if -1000001 < n < 1000001:
		if n > -1:
			return _fc[n]
		else:
			return -_fc[abs(n)]
	else:
		raise ValueError('values only from 1000000 to -1000000 can be factorialized\n')

def yn(b, caps=False, y='Yes', n='No'):
	if b:
		returning = y
	else:
		returning = n
	if caps == 2:
		return returning.lower()
	elif caps == 3:
		return ''.join([returning[i].lower() if i % 2 == 0 else returning[i].upper() for i in range(len(returning))])
	elif caps:
		return returning.upper()
	return returning

def prob(l, n):
	return l.count(n) / len(l)

def isSubseq(s1, s2):
	(n, m) = (len(s1), len(s2))
	(i, j) = (0, 0)
	while i < n and j < m:
		if s1[i] == s2[j]:
			i += 1
		j += 1
	return i == n

def isPrime(n):
	if n > 1:
		for i in range(2, int(n ** 0.5) + 1):
			if not n % i:
				return False
		else:
			return True
	return True

def percentDiff(n, diff):
	return n + n * (diff / 100)

def prodLst(l1, nl):
	if isinstance(nl, int):
		return [i * nl for i in l1]
	else:
		return [i * j for (i, j) in zip(l1, nl)]

def divLst(l1, nl, mxMn=False):
	if isinstance(nl, int):
		return [i // nl for i in l1]
	elif mxMn:
		return [max(i, j) // min(i, j) for (i, j) in zip(l1, nl)]
	else:
		return [i // j for (i, j) in zip(l1, nl)]

def modLst(l, n):
	return [i % n for i in l]

def sumLst(l1, nl):
	if isinstance(nl, int):
		return [i + nl for i in l1]
	else:
		return [i + j for (i, j) in zip(l1, nl)]

def absLst(l):
	return [abs(i) for i in l]

def diffLst(l1, nl, isAbs=False):
	if isinstance(nl, int):
		returning = [i - nl for i in l1]
	else:
		returning = [i - j for (i, j) in zip(l1, nl)]
	if isAbs:
		return absLst(returning)
	else:
		return returning

def remCommonOccurs(l, remLst):
	srl = set(remLst)
	returning = []
	for i in l:
		if i not in remLst:
			returning.append(i)
	return returning

def remPosNeg(l, posNeg=False):
	returning = []
	if not posNeg:
		for i in l:
			if i >= 0:
				returning.append(i)
	else:
		for i in l:
			if i < 0:
				returning.append(i)
	return returning

def flip(nl):
	if isinstance(nl, int):
		return -nl
	elif isinstance(nl, list):
		return [-i for i in nl]

def ev(n):
	return not n & 1

def decimal(n):
	returning = int(n)
	if list(set(str(n)[str(n).index('.') + 1:])) == ['0']:
		return returning
	else:
		return returning + 1

def printdeci(n):
	print(decimal(n))

def printabs(n):
	print(abs(n))

def printm(n):
	print(mod(n))

def printy(b, caps=False, y='Yes', n='No'):
	print(yn(b, caps, y, n))

class mutableStr(UserString):

	def ins(self, n, s):
		if n < 0:
			self.data = self.data = ''.join(list(self.data)[:n + 1]) + s + ''.join(list(self.data)[n + 1:])
		else:
			self.data = ''.join(list(self.data)[:n]) + s + ''.join(list(self.data)[n:])

	def rem(self, s):
		self.data = self.data.replace(s, '')
alphabetOrd = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
alphabet = list('abcdefghijklmnopqrstuvwxyz')
listToStr = lambda l: ''.join(map(str, l))
bint = lambda b: int(str(b), 2)
r2 = lambda n: range(1, n + 1)
rl = lambda *l: range(len(l[0])) if len(l) == 1 else range(l[0], len(l[1]))
alph = lambda s: s.isalpha()
sl = lambda l: list(set(l))
inf = float('inf')
soi = lambda : sorted(input())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
si = lambda : mutableStr(str(input()))
lsi = lambda : list(input())
sepi = lambda : map(int, input().split())
seti = lambda : set(map(int, input().split()))
for t in range(int(input())):
	row1 = si()
	row2 = si()
	ans = []
	revColour = {'W': 'B', 'B': 'W'}
	for i in rl(row1):
		ans.append(revColour[row1[i]] * int(row1[i] == row2[i]))
		ans.append('B' * int(row1[i] != row2[i]))
	print(listToStr(ans))


t = int(input())
for i in range(t):
	x = input()
	y = input()
	z = ''
	cnt = 0
	for i in range(len(x)):
		if x[i] == 'W' and y[i] == 'W':
			z = z + 'B'
		elif x[i] == 'W' and y[i] == 'B':
			z = z + 'B'
		elif x[i] == 'B' and y[i] == 'W':
			z = z + 'B'
		else:
			z = z + 'W'
	print(z)


for _ in range(int(input())):
	(a, b) = (input(), input())
	s = ''
	for i in range(len(a)):
		if a[i] == b[i] == 'W':
			s += 'B'
		elif a[i] == b[i] == 'B':
			s += 'W'
		else:
			s += 'B'
	print(s)


t = int(input())
for i in range(t):
	str1 = input()
	str2 = input()
	res1 = ''
	for j in range(len(str1)):
		if str1[j] == 'W' and str2[j] == 'W':
			res1 += 'B'
		elif str1[j] == 'B' and str2[j] == 'B':
			res1 += 'W'
		else:
			res1 += 'B'
	print(res1)


t = int(input())
for ni in range(t):
	x = input()
	y = input()
	for i in range(len(x)):
		if x[i] == y[i] and x[i] == 'B':
			print('W', end='')
		else:
			print('B', end='')
	print(' ')


casos = int(input())
for i in range(casos):
	primera_fila = input()
	segunda_fila = input()
	tercera_fila = ''
	for i in range(len(primera_fila)):
		if primera_fila[i] == segunda_fila[i]:
			if primera_fila[i] == 'W':
				tercera_fila += 'B'
			else:
				tercera_fila += 'W'
		else:
			tercera_fila += 'B'
	print(tercera_fila)