A bitstring is a string that contains only the characters 0 and 1.

Koyomi Kanou is working hard towards her dream of becoming a writer. To practice, she decided to participate in the Binary Novel Writing Contest. The writing prompt for the contest consists of three bitstrings of length $2n$. A valid novel for the contest is a bitstring of length at most $3n$ that contains at least two of the three given strings as subsequences.

Koyomi has just received the three prompt strings from the contest organizers. Help her write a valid novel for the contest.

A string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero) characters.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^5$).

Each of the following three lines contains a bitstring of length $2n$. It is guaranteed that these three strings are pairwise distinct.

It is guaranteed that the sum of $n$ across all test cases does not exceed $10^5$.


-----Output-----

For each test case, print a single line containing a bitstring of length at most $3n$ that has at least two of the given bitstrings as subsequences.

It can be proven that under the constraints of the problem, such a bitstring always exists.

If there are multiple possible answers, you may output any of them.


-----Examples-----

Input
2
1
00
11
01
3
011001
111010
010001
Output
010
011001010


-----Note-----

In the first test case, the bitstrings 00 and 01 are subsequences of the output string: 010 and 010. Note that 11 is not a subsequence of the output string, but this is not required.

In the second test case all three input strings are subsequences of the output string: 011001010, 011001010 and 011001010.

Source: codeforces | Difficulty: HARD
Tags: Constructive algorithms

String algorithms

Amortized analysis

Implementation

Greedy algorithms


Solutions:
from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def A(n):
	return [0] * n

def AI(n, x):
	return [x] * n

def A2(n, m):
	return [[0] * m for i in range(n)]

def G(n):
	return [[] for i in range(n)]

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
mod = 10 ** 9 + 7
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		seen.add(u)
		for (v, w) in graph[u]:
			if v not in d or d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

def bell(s, g):
	dis = AI(n, inf)
	dis[s] = 0
	for i in range(n - 1):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
	change = A(n)
	for i in range(n):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
				change[v] = 1
	return dis

def lcm(a, b):
	return a * b // gcd(a, b)

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j, n, m):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None

def cal(x):
	ans = 0
	for i in range(2 * n):
		ans += x[i] == '1'
	return ans

def f(x, y, ch):
	ans = []
	i = j = 0
	c = 0
	while True:
		while i < 2 * n and x[i] != ch:
			ans.append(x[i])
			i += 1
		while j < 2 * n and y[j] != ch:
			ans.append(y[j])
			j += 1
		ans.append(x[i])
		i += 1
		j += 1
		c += 1
		if c >= n:
			break
	ans = ans + x[i:] + y[j:]
	return ''.join(ans)
t = N()
for i in range(t):
	n = N()
	a = list(input())
	b = list(input())
	c = list(input())
	ca = cal(a)
	cb = cal(b)
	cc = cal(c)
	res = [[a, ca], [b, cb], [c, cc]]
	res.sort(key=lambda x: x[1])
	([a, ca], [b, cb], [c, cc]) = res
	if cb >= n:
		ans = f(b, c, '1')
	else:
		ans = f(a, b, '0')
	print(ans)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = input()
	s = []
	ind = [0, 0, 0]
	while ind[0] < 2 * n and ind[1] < 2 * n and (ind[2] < 2 * n):
		f = [False, False, False]
		if a[ind[0]] == '1':
			f[0] = True
		if b[ind[1]] == '1':
			f[1] = True
		if c[ind[2]] == '1':
			f[2] = True
		if sum(f) > 1:
			s.append('1')
			for i in range(3):
				if f[i]:
					ind[i] += 1
		else:
			s.append('0')
			for i in range(3):
				if not f[i]:
					ind[i] += 1
	if ind[0] != 2 * n and 2 * n - ind[0] <= 3 * n - len(s):
		for i in range(ind[0], len(a)):
			s.append(a[i])
	if ind[1] != 2 * n and 2 * n - ind[1] <= 3 * n - len(s):
		for i in range(ind[1], len(b)):
			s.append(b[i])
	if ind[2] != 2 * n and 2 * n - ind[2] <= 3 * n - len(s):
		for i in range(ind[2], len(c)):
			s.append(c[i])
	print(''.join(s))


def merge(x, y, c):
	N = len(x)
	n = N // 2
	ans = ''
	(i, j) = (0, 0)
	while i < N and j < N:
		if x[i] == y[j]:
			ans += x[i]
			i += 1
			j += 1
		elif x[i] != c:
			ans += x[i]
			i += 1
		else:
			ans += y[j]
			j += 1
	ans += x[i:] + y[j:]
	ans += '0' * (3 * n - len(ans))
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	S = [input(), input(), input()]
	C0 = [j for j in range(3) if S[j].count('0') >= n]
	if len(C0) >= 2:
		print(merge(S[C0[0]], S[C0[1]], '0'))
	else:
		C1 = [j for j in range(3) if j not in C0]
		print(merge(S[C1[0]], S[C1[1]], '1'))


import sys
input = sys.stdin.readline

def mix(x, y):
	if x.count('0') >= n and y.count('0') >= n:
		ANS = []
		i = 0
		j = 0
		while i < 2 * n or j < 2 * n:
			counti = 0
			countj = 0
			while i < n * 2 and x[i] == '1':
				counti += 1
				i += 1
			while j < n * 2 and y[j] == '1':
				countj += 1
				j += 1
			ANS += ['1'] * max(counti, countj)
			if i < 2 * n and x[i] == '0' or (j < 2 * n and y[j] == '0'):
				ANS.append('0')
			i += 1
			j += 1
		return ANS
	elif x.count('1') >= n and y.count('1') >= n:
		ANS = []
		i = 0
		j = 0
		while i < 2 * n or j < 2 * n:
			counti = 0
			countj = 0
			while i < n * 2 and x[i] == '0':
				counti += 1
				i += 1
			while j < n * 2 and y[j] == '0':
				countj += 1
				j += 1
			ANS += ['0'] * max(counti, countj)
			if i < 2 * n and x[i] == '1' or (j < 2 * n and y[j] == '1'):
				ANS.append('1')
			i += 1
			j += 1
		return ANS
	else:
		return -1
t = int(input())
for tests in range(t):
	n = int(input())
	S = [list(input().strip()) for i in range(3)]
	flag = 0
	for i in range(3):
		if flag == 1:
			break
		for j in range(3):
			if i == j:
				continue
			k = mix(S[i], S[j])
			if k == -1:
				continue
			else:
				flag = 1
				break
	print(''.join(k))


from sys import *
input = stdin.readline

def superstring(x, y, fx, n):
	ans = ''
	(i, j) = (0, 0)
	while i < 2 * n and j < 2 * n:
		if x[i] == y[j]:
			ans += x[i]
			i += 1
			j += 1
		elif x[i] != fx:
			ans += x[i]
			i += 1
		else:
			ans += y[j]
			j += 1
	return ans + x[i:] + y[j:]
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = (input().strip(), input().strip(), input().strip())
	(one, zero) = ([], [])
	for i in [a, b, c]:
		if i.count('0') >= n:
			zero.append(i)
		else:
			one.append(i)
	currans = ''
	if len(zero) > len(one):
		currans = superstring(zero[0], zero[1], '0', n)
	else:
		currans = superstring(one[0], one[1], '1', n)
	print(currans.rjust(3 * n, '0'))


from itertools import product

def mix(tpl, c):
	(a, b) = tpl
	n = len(a)
	ans = []
	(ap, bp) = (0, 0)
	while True:
		while ap < n and a[ap] != c:
			ans.append(a[ap])
			ap += 1
		while bp < n and b[bp] != c:
			ans.append(b[bp])
			bp += 1
		if ap < n or bp < n:
			ans.append(c)
			ap += 1
			bp += 1
		if ap >= n and bp >= n:
			break
	return ''.join(ans)

def solve():
	n = int(input())
	(a, b, c) = [input() for i in range(3)]
	return min([mix(*p) for p in product([(a, b), (b, c), (c, a)], '01')], key=len)
t = int(input())
for tc in range(t):
	print(solve())


def f(s1, s2, n, c):
	(i1, i2) = (0, 0)
	nz = 0
	l = []
	b = True
	while i1 + i2 != 4 * n:
		if i1 == 2 * n:
			b = False
		if i2 == 2 * n:
			b = True
		if b:
			if s1[i1] == c and nz < n:
				b = False
			else:
				l.append(s1[i1])
			i1 += 1
		else:
			if s2[i2] == c and nz < n:
				b = True
				l.append(c)
				nz += 1
			else:
				l.append(s2[i2])
			i2 += 1
	print(''.join(l))
for kT in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	s3 = input()
	nz1 = s1.count('0')
	nz2 = s2.count('0')
	nz3 = s3.count('0')
	if nz1 >= n:
		if nz2 >= n:
			f(s1, s2, n, '0')
		elif nz3 >= n:
			f(s1, s3, n, '0')
		else:
			f(s2, s3, n, '1')
	elif nz2 < n:
		f(s1, s2, n, '1')
	elif nz3 < n:
		f(s1, s3, n, '1')
	else:
		f(s2, s3, n, '0')


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input()]
	B = [int(a) for a in input()]
	C = [int(a) for a in input()]
	aa = 1 if A.count(0) >= N else 0
	bb = 1 if B.count(0) >= N else 0
	cc = 1 if C.count(0) >= N else 0
	f = 0
	if aa == bb:
		pass
	elif aa == cc:
		bb = cc
		B = C
	elif bb == cc:
		aa = cc
		A = C
	if aa == 0:
		f = 1
		A = [a ^ 1 for a in A]
		B = [a ^ 1 for a in B]
	S = []
	while A and B:
		if A[-1] == B[-1]:
			S.append(A.pop())
			B.pop()
		elif A[-1] == 1:
			S.append(1)
			A.pop()
		else:
			S.append(1)
			B.pop()
	while A:
		S.append(A.pop())
	while B:
		S.append(B.pop())
	if f:
		S = [a ^ 1 for a in S]
	print(''.join(map(str, reversed(S))))


tc = int(input())
for i in range(tc):
	n = int(input())
	s = [input() for _ in range(3)]
	p = [0] * 3
	ans = ''
	while True:
		ones = []
		oc = 0
		zeroes = []
		for i in range(3):
			if s[i][p[i]] == '1':
				ones.append(i)
				oc += 1
			else:
				zeroes.append(i)
		if oc >= 2:
			print('1', end='')
			for i in ones:
				p[i] += 1
		else:
			print('0', end='')
			for i in zeroes:
				p[i] += 1
		if p[0] == 2 * n or p[1] == 2 * n or p[2] == 2 * n:
			break
	x = sorted(enumerate(p), key=lambda i: i[1])
	print(s[x[1][0]][x[1][1]:])


import sys

def input():
	return sys.stdin.readline().rstrip()

def slv():
	n = int(input())
	a = list(map(lambda x: int(x), list(input())))
	b = list(map(lambda x: int(x), list(input())))
	c = list(map(lambda x: int(x), list(input())))
	(aindex, bindex, cindex) = (0, 0, 0)
	ans = []
	addition = 0
	while max(aindex, bindex, cindex) < 2 * n:
		addition += 1
		(zero_count, one_count) = (0, 0)
		if a[aindex] == 0:
			zero_count += 1
		else:
			one_count += 1
		if b[bindex] == 0:
			zero_count += 1
		else:
			one_count += 1
		if c[cindex] == 0:
			zero_count += 1
		else:
			one_count += 1
		if zero_count > one_count:
			ans.append(0)
			if a[aindex] == 0:
				aindex += 1
			if b[bindex] == 0:
				bindex += 1
			if c[cindex] == 0:
				cindex += 1
			continue
		else:
			ans.append(1)
			if a[aindex] == 1:
				aindex += 1
			if b[bindex] == 1:
				bindex += 1
			if c[cindex] == 1:
				cindex += 1
			continue
	left_addition = 3 * n - addition
	satisfied = 0
	if aindex == 2 * n:
		satisfied += 1
	if bindex == 2 * n:
		satisfied += 1
	if cindex == 2 * n:
		satisfied += 1
	if satisfied >= 2:
		ans_string = ''.join(map(lambda x: str(x), ans))
		print(ans_string)
		return
	else:
		if aindex < 2 * n and aindex + left_addition >= 2 * n:
			for i in range(aindex, 2 * n):
				ans.append(a[i])
		elif bindex < 2 * n and bindex + left_addition >= 2 * n:
			for i in range(bindex, 2 * n):
				ans.append(b[i])
		elif cindex < 2 * n and cindex + left_addition >= 2 * n:
			for i in range(cindex, 2 * n):
				ans.append(c[i])
		ans_string = ''.join(map(lambda x: str(x), ans))
		print(ans_string)
	return

def main():
	t = int(input())
	for i in range(t):
		slv()
	return
main()


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	s = []
	for i in range(3):
		s.append(input())
	s1 = []
	s0 = []
	for i in range(3):
		s0.append(s[i].count('0'))
		s1.append(2 * n - s0[-1])
	for i in range(2):
		for j in range(i + 1, 3):
			if s0[i] >= n and s0[j] >= n:
				c1 = i
				c2 = j
				g = '0'
				b = '1'
			if s1[i] >= n and s1[j] >= n:
				c1 = i
				c2 = j
				g = '1'
				b = '0'
	i = j = 0
	while i < 2 * n or j < 2 * n:
		if i < 2 * n and s[c1][i] == b:
			i += 1
			print(end=b)
		elif j < 2 * n and s[c2][j] == b:
			j += 1
			print(end=b)
		else:
			print(end=g)
			i += 1
			j += 1
	print()


import os, sys
from io import BytesIO, IOBase

def solve(n, ls):
	(x, y) = ([i.count('0') for i in ls], [i.count('1') for i in ls])
	for i in range(3):
		for j in range(3):
			if i == j:
				continue
			if x[i] >= n and x[j] >= n:
				(ans, b) = ([], 0)
				for a in ls[i]:
					if a == '1':
						ans.append('1')
						continue
					while b != 2 * n and ls[j][b] != '0':
						ans.append('1')
						b += 1
					ans.append('0')
					if b != 2 * n:
						b += 1
				while b != 2 * n:
					ans.append(ls[j][b])
					b += 1
				return ''.join(ans)
			if y[i] >= n and y[j] >= n:
				(ans, b) = ([], 0)
				for a in ls[i]:
					if a == '0':
						ans.append('0')
						continue
					while b != 2 * n and ls[j][b] != '1':
						ans.append('0')
						b += 1
					ans.append('1')
					if b != 2 * n:
						b += 1
				while b != 2 * n:
					ans.append(ls[j][b])
					b += 1
				return ''.join(ans)

def main():
	for _ in range(int(input())):
		n = int(input())
		ls = [input().strip() for _ in range(3)]
		print(solve(n, ls))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def merge(x, y, dict_x, dict_y, c):
	N = len(x)
	n = N // 2
	(v1, v2) = ([-1] + dict_x[c], [-1] + dict_y[c])
	ans = ''
	for i in range(n):
		for j in range(v1[i] + 1, v1[i + 1]):
			ans += x[j]
		for j in range(v2[i] + 1, v2[i + 1]):
			ans += y[j]
		ans += c
	ans += ''.join([x[j] for j in range(v1[n] + 1, N)])
	ans += ''.join([y[j] for j in range(v2[n] + 1, N)])
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	S = [input(), input(), input()]
	D = [{'0': [], '1': []} for i in range(3)]
	for i in range(3):
		for (j, c) in enumerate(S[i]):
			D[i][c].append(j)
	M0 = [i for i in range(3) if len(D[i]['0']) >= n]
	M1 = [i for i in range(3) if len(D[i]['1']) >= n]
	ans = ''
	if len(M0) >= 2:
		(i1, i2) = M0[:2]
		ans = merge(S[i1], S[i2], D[i1], D[i2], '0')
	else:
		(i1, i2) = M1[:2]
		ans = merge(S[i1], S[i2], D[i1], D[i2], '1')
	print(ans)


import io
from itertools import permutations
import os
from collections import Counter, defaultdict, deque

def solve(N, S):
	freq = [Counter(s) for s in S]
	for common in '01':
		good = []
		for i in range(3):
			if freq[i][common] >= N:
				good.append(i)
		if len(good) >= 2:
			(i, j) = good[:2]
			s1 = S[i]
			s2 = S[j]
			i = 0
			j = 0
			ans = []
			check = 0
			while i < 2 * N and j < 2 * N:
				if check < N:
					if s1[i] == common:
						while s2[j] != common:
							ans.append(s2[j])
							j += 1
						assert s1[i] == s2[j] == common
						ans.append(s1[i])
						i += 1
						j += 1
						check += 1
					elif s2[j] == common:
						while s1[i] != common:
							ans.append(s1[i])
							i += 1
						assert s1[i] == s2[j] == common
						ans.append(s1[i])
						i += 1
						j += 1
						check += 1
					else:
						ans.append(s1[i])
						i += 1
						ans.append(s2[j])
						j += 1
				else:
					break
			while i < 2 * N:
				ans.append(s1[i])
				i += 1
			while j < 2 * N:
				ans.append(s2[j])
				j += 1
			assert len(ans) <= 3 * N
			while len(ans) < 3 * N:
				ans.append('0')
			return ''.join(ans)
	assert False
DEBUG = False
if DEBUG:
	import random
	random.seed(0)
	for _ in range(100000):
		N = random.randint(1, 10)
		A = [str(random.randint(0, 1)) for i in range(2 * N)]
		B = [str(random.randint(0, 1)) for i in range(2 * N)]
		C = [str(random.randint(0, 1)) for i in range(2 * N)]
		print('tc' + str(_), N, A)
		ans = solve(N, [A, B, C])
	exit()
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	S = [input().decode().rstrip() for i in range(3)]
	ans = solve(N, S)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = input()
	(i, j, k) = (0, 0, 0)
	res = []
	while True:
		if i == 2 * n:
			if j >= k:
				for x in range(j, 2 * n):
					res.append(b[x])
			else:
				for x in range(k, 2 * n):
					res.append(c[x])
			break
		elif j == 2 * n:
			if i >= k:
				for x in range(i, 2 * n):
					res.append(a[x])
			else:
				for x in range(k, 2 * n):
					res.append(c[x])
			break
		elif k == 2 * n:
			if j >= i:
				for x in range(j, 2 * n):
					res.append(b[x])
			else:
				for x in range(i, 2 * n):
					res.append(a[x])
			break
		if a[i] == b[j]:
			res.append(a[i])
			i += 1
			j += 1
		elif b[j] == c[k]:
			res.append(b[j])
			j += 1
			k += 1
		else:
			res.append(a[i])
			i += 1
			k += 1
	print(*res, sep='')


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = []
		a.append(input())
		a.append(input())
		a.append(input())
		zeroDominant = []
		oneDominant = []
		for k in range(3):
			cnt = 0
			for i in range(2 * n):
				if a[k][i] == '1':
					cnt += 1
			if cnt >= n:
				oneDominant.append(a[k])
			else:
				zeroDominant.append(a[k])
		if len(oneDominant) >= 2:
			n *= 2
			ans = []
			fIndex = 0
			lIndex = 0
			while fIndex < n or lIndex < n:
				if fIndex == n and lIndex < n:
					ans.append(oneDominant[1][lIndex])
					lIndex += 1
				elif lIndex == n and fIndex < n:
					ans.append(oneDominant[0][fIndex])
					fIndex += 1
				elif oneDominant[0][fIndex] == oneDominant[1][lIndex]:
					ans.append(oneDominant[0][fIndex])
					fIndex += 1
					lIndex += 1
				else:
					ans.append('0')
					if oneDominant[0][fIndex] == '0':
						fIndex += 1
					else:
						lIndex += 1
			print(''.join(ans))
		else:
			n *= 2
			ans = []
			fIndex = 0
			lIndex = 0
			while fIndex < n or lIndex < n:
				if fIndex == n and lIndex < n:
					ans.append(zeroDominant[1][lIndex])
					lIndex += 1
				elif lIndex == n and fIndex < n:
					ans.append(zeroDominant[0][fIndex])
					fIndex += 1
				elif zeroDominant[0][fIndex] == zeroDominant[1][lIndex]:
					ans.append(zeroDominant[0][fIndex])
					fIndex += 1
					lIndex += 1
				else:
					ans.append('1')
					if zeroDominant[0][fIndex] == '1':
						fIndex += 1
					else:
						lIndex += 1
			print(''.join(ans))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
tc = 1
tc = int(input())
for test in range(1, tc + 1):
	n = int(input())
	s1 = str(input())
	s2 = str(input())
	s3 = str(input())
	o1 = s1.count('1')
	z1 = 2 * n - o1
	o2 = s2.count('1')
	z2 = 2 * n - o2
	o3 = s3.count('1')
	z3 = 2 * n - o3

	def solve(s1, s2, k):
		ans = []
		i = 0
		j = 0
		n = len(s1)
		while i < n and j < n:
			if s1[i] == s2[j]:
				ans.append(s1[i])
				i += 1
				j += 1
			elif s1[i] == k:
				ans.append(s2[j])
				j += 1
			else:
				ans.append(s1[i])
				i += 1
		while i < n:
			ans.append(s1[i])
			i += 1
		while j < n:
			ans.append(s2[j])
			j += 1
		return ''.join(ans) + '0' * (n // 2 * 3 - len(ans))
	if o1 >= n and o2 >= n:
		ans = solve(s1, s2, '1')
	elif o2 >= n and o3 >= n:
		ans = solve(s2, s3, '1')
	elif o1 >= n and o3 >= n:
		ans = solve(s1, s3, '1')
	elif z1 >= n and z2 >= n:
		ans = solve(s1, s2, '0')
	elif z2 >= n and z3 >= n:
		ans = solve(s2, s3, '0')
	else:
		ans = solve(s1, s3, '0')
	print(ans)


from sys import stdin
input = stdin.readline

def good(a, b, ch):
	(cnt1, cnt2) = (0, 0)
	n = len(a)
	for i in range(n):
		if a[i] == ch:
			cnt1 += 1
		if b[i] == ch:
			cnt2 += 1
	(i, j) = (0, 0)
	ans = ''
	if min(cnt1, cnt2) >= n // 2:
		while i < n and j < n:
			if a[i] == b[j] == ch:
				ans += ch
				i += 1
				j += 1
			else:
				if a[i] != ch:
					ans += a[i]
					i += 1
				if b[j] != ch:
					ans += b[j]
					j += 1
	while i < n:
		ans += a[i]
		i += 1
	while j < n:
		ans += b[j]
		j += 1
	if len(ans) <= n // 2 * 3:
		print(ans)
		return True
	else:
		return False

def f(b, n):
	lst = [(b[0], b[1]), (b[0], b[2]), (b[1], b[2])]
	for i in lst:
		x = good(i[0], i[1], '1')
		if x:
			return ''
		x = good(i[0], i[1], '0')
		if x:
			return ''
for i in range(int(input())):
	n = int(input())
	b = []
	for j in range(3):
		b.append(input().strip())
	print(f(b, n))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	S1 = input().strip()
	S2 = input().strip()
	S3 = input().strip()
	for s1 in (S1, S2, S3):
		for s2 in (S1, S2, S3):
			if s1 == s2:
				continue
			z1 = s1.count('0')
			o1 = s1.count('1')
			z2 = s2.count('0')
			o2 = s2.count('1')
			mz = max(z1, z2)
			mo = max(o1, o2)
			if mz > n and mo > n:
				continue
			if mz <= n:
				cnt1 = []
				cnt2 = []
				bef = '0'
				cnt = 0
				for s in s1:
					if s == '1':
						cnt1.append(cnt)
						cnt = 0
					else:
						cnt += 1
					bef = s
				if cnt:
					cnt1.append(cnt)
				bef = '0'
				cnt = 0
				for s in s2:
					if s == '1':
						cnt2.append(cnt)
						cnt = 0
					else:
						cnt += 1
					bef = s
				if cnt:
					cnt2.append(cnt)
				if len(cnt1) > len(cnt2):
					cnt2 += [0] * (len(cnt1) - len(cnt2))
				elif len(cnt1) < len(cnt2):
					cnt1 += [0] * (len(cnt2) - len(cnt1))
				ans = []
				for (c1, c2) in zip(cnt1, cnt2):
					ans += ['0'] * max(c1, c2)
					ans += ['1']
				ans.pop()
				if len(ans) < 3 * n:
					ans += ['1'] * (3 * n - len(ans))
				print(''.join(ans))
				return
			elif mo <= n:
				cnt1 = []
				cnt2 = []
				bef = '1'
				cnt = 0
				for s in s1:
					if s == '0':
						cnt1.append(cnt)
						cnt = 0
					else:
						cnt += 1
					bef = s
				if cnt:
					cnt1.append(cnt)
				bef = '1'
				cnt = 0
				for s in s2:
					if s == '0':
						cnt2.append(cnt)
						cnt = 0
					else:
						cnt += 1
					bef = s
				if cnt:
					cnt2.append(cnt)
				if len(cnt1) > len(cnt2):
					cnt2 += [0] * (len(cnt1) - len(cnt2))
				elif len(cnt1) < len(cnt2):
					cnt1 += [0] * (len(cnt2) - len(cnt1))
				ans = []
				for (c1, c2) in zip(cnt1, cnt2):
					ans += ['1'] * max(c1, c2)
					ans += ['0']
				ans.pop()
				if len(ans) < 3 * n:
					ans += ['0'] * (3 * n - len(ans))
				print(''.join(ans))
				return
for _ in range(int(input())):
	main()


import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def nck(n, k, kaijyo):
	return npk(n, k, kaijyo) * divide(kaijyo[k]) % MOD

def npk(n, k, kaijyo):
	if k == 0 or k == n:
		return n % MOD
	return kaijyo[n] * divide(kaijyo[n - k]) % MOD

def fact_and_inv(SIZE):
	inv = [0] * SIZE
	fac = [0] * SIZE
	finv = [0] * SIZE
	inv[1] = 1
	fac[0] = fac[1] = 1
	finv[0] = finv[1] = 1
	for i in range(2, SIZE):
		inv[i] = MOD - MOD // i * inv[MOD % i] % MOD
		fac[i] = fac[i - 1] * i % MOD
		finv[i] = finv[i - 1] * inv[i] % MOD
	return (fac, finv)

def renritsu(A, Y):
	A = np.matrix(A)
	Y = np.matrix(Y)
	Y = np.reshape(Y, (-1, 1))
	X = np.linalg.solve(A, Y)
	return X.flatten().tolist()[0]

class TwoDimGrid:

	def __init__(self, h, w, wall='#'):
		self.h = h
		self.w = w
		self.size = (h + 2) * (w + 2)
		self.wall = wall
		self.get_grid()

	def get_grid(self):
		grid = [self.wall * (self.w + 2)]
		for i in range(self.h):
			grid.append(self.wall + getS() + self.wall)
		grid.append(self.wall * (self.w + 2))
		self.grid = grid

	def init_cost(self):
		self.cost = [INF] * self.size

	def pos(self, x, y):
		return y * (self.w + 2) + x

	def getgrid(self, x, y):
		return self.grid[y][x]

	def get(self, x, y):
		return self.cost[self.pos(x, y)]

	def set(self, x, y, v):
		self.cost[self.pos(x, y)] = v
		return

	def show(self):
		for i in range(self.h + 2):
			print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

	def showsome(self, tgt):
		for t in tgt:
			print(t)
		return

	def showsomejoin(self, tgt):
		for t in tgt:
			print(''.join(t))
		return

	def search(self):
		grid = self.grid
		move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
		move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]

class BIT:

	def __init__(self, n):
		self.n = n
		self.BIT = [0] * (n + 2)

	def query(self, idx):
		res_sum = 0
		while idx > 0:
			res_sum += self.BIT[idx]
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		while idx <= self.n:
			self.BIT[idx] += x
			idx += idx & -idx
		return

	def show(self):
		print(self.BIT)

def solve():
	n = getN()
	a = [getS(), getS(), getS()]
	idx = [0, 0, 0]
	ans = []
	while True:
		(on, tw) = ([], [])
		for (i, x) in enumerate(idx):
			if a[i][x] == '1':
				on.append(i)
			else:
				tw.append(i)
		if len(on) > len(tw):
			ans.append('1')
			for i in on:
				idx[i] += 1
		else:
			ans.append('0')
			for i in tw:
				idx[i] += 1
		if 2 * n in idx:
			break
	if idx[0] == 2 * n:
		if idx[1] > idx[2]:
			ans += list(a[1][idx[1]:])
		else:
			ans += list(a[2][idx[2]:])
	elif idx[1] == 2 * n:
		if idx[0] > idx[2]:
			ans += list(a[0][idx[0]:])
		else:
			ans += list(a[2][idx[2]:])
	elif idx[1] > idx[0]:
		ans += list(a[1][idx[1]:])
	else:
		ans += list(a[0][idx[0]:])
	print(''.join(ans))
	return

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	s1 = input()
	s2 = input()
	s3 = input()
	fincount = 0
	count10 = 0
	for i in range(2 * n):
		if s1[i] == '0':
			count10 += 1
	if count10 >= n:
		fincount += 1
	count20 = 0
	for i in range(2 * n):
		if s2[i] == '0':
			count20 += 1
	if count20 >= n:
		fincount += 1
	count30 = 0
	for i in range(2 * n):
		if s3[i] == '0':
			count30 += 1
	if count30 >= n:
		fincount += 1
	if fincount >= 2:
		mode = '0'
		unmode = '1'
	else:
		mode = '1'
		unmode = '0'
	if mode == '0':
		if count10 >= n and count20 >= n:
			st1 = s1
			st2 = s2
		elif count10 >= n and count30 >= n:
			st1 = s1
			st2 = s3
		elif count20 >= n and count30 >= n:
			st1 = s2
			st2 = s3
	elif count10 <= n and count20 <= n:
		st1 = s1
		st2 = s2
	elif count10 <= n and count30 <= n:
		st1 = s1
		st2 = s3
	elif count20 <= n and count30 <= n:
		st1 = s2
		st2 = s3
	pointer1 = 0
	pointer2 = 0
	while pointer1 < 2 * n or pointer2 < 2 * n:
		while pointer1 < 2 * n and st1[pointer1] == unmode:
			pointer1 += 1
			ans.append(unmode)
		while pointer2 < 2 * n and st2[pointer2] == unmode:
			pointer2 += 1
			ans.append(unmode)
		if pointer1 >= 2 * n and pointer2 >= 2 * n:
			break
		ans.append(mode)
		pointer1 += 1
		pointer2 += 1
	print(''.join(ans))


import sys, io, os
try:
	Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	Z = lambda : sys.stdin.readline().encode()
Y = lambda : Z().strip()
O = []
for _ in range(int(Z())):
	n = int(Z())
	a = Y()
	b = Y()
	c = Y()
	(ca, cb, cc) = (a.count(49) >= n, b.count(49) >= n, c.count(49) >= n)
	if ca == cb:
		(x, y) = (a, b)
		d = ca
	elif ca == cc:
		(x, y) = (a, c)
		d = ca
	else:
		(x, y) = (b, c)
		d = cb
	if x.count(48 + d) > y.count(48 + d):
		(x, y) = (y, x)
	r = []
	p = 0
	for i in range(2 * n):
		if x[i] & 1 == d:
			while y[p] & 1 != d:
				r.append(1 - d)
				p += 1
			r.append(0 + d)
			p += 1
		else:
			r.append(1 - d)
	while p < 2 * n:
		r.append(y[p] & 1)
		p += 1
	for i in range(3 * n - len(r)):
		r.append(0)
	O.append(''.join(map(str, r)))
print('\n'.join(O))


import itertools

def solve(a, b):
	if a.count('1') * 2 >= len(a) and b.count('1') * 2 >= len(b):
		ch = '1'
		other = '0'
	else:
		ch = '0'
		other = '1'
	res = []
	i = 0
	j = 0
	ilast = -1
	jlast = -1
	while i < len(a) and j < len(b):
		while i < len(a) and a[i] != ch:
			i += 1
		while j < len(b) and b[j] != ch:
			j += 1
		res.append(other * max(i - ilast - 1, j - jlast - 1))
		if i != len(a) or j != len(b):
			res.append(ch)
		ilast = i
		jlast = j
		i += 1
		j += 1
	while i < len(a):
		res.append(a[i])
		i += 1
	while j < len(b):
		res.append(b[j])
		j += 1
	return ''.join(res)
for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = input()
	na1 = a.count('1')
	nb1 = b.count('1')
	nc1 = c.count('1')
	res = None
	if na1 >= n and nb1 >= n or (na1 <= n and nb1 <= n):
		res = solve(a, b)
	elif na1 >= n and nc1 >= n or (na1 <= n and nc1 <= n):
		res = solve(a, c)
	elif nb1 >= n and nc1 >= n or (nb1 <= n and nc1 <= n):
		res = solve(b, c)
	else:
		raise RuntimeError('unexpected')
	print(res)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s1 = stdin.readline(2 * n)
	stdin.readline(1)
	s2 = stdin.readline(2 * n)
	stdin.readline(1)
	s3 = stdin.readline(2 * n)
	stdin.readline(1)
	strings = [s1, s2, s3]
	strings.sort(key=lambda x: x.count('0'))
	if strings[1].count('0') >= n:
		(s1, s2) = (strings[2], strings[1])
		for i in range(2 * n):
			if s2[i] == '1':
				stdout.write('1')
			else:
				break
		idx = i
		for i in range(2 * n):
			if s1[i] == '1':
				stdout.write('1')
			else:
				stdout.write('0')
				idx += 1
				for j in range(idx, 2 * n):
					if s2[j] == '1':
						stdout.write('1')
					else:
						break
				idx = j
		stdout.write('\n')
		continue
	strings.sort(key=lambda x: x.count('1'))
	if strings[1].count('1') >= n:
		(s1, s2) = (strings[2], strings[1])
		for i in range(2 * n):
			if s2[i] == '0':
				stdout.write('0')
			else:
				break
		idx = i
		for i in range(2 * n):
			if s1[i] == '0':
				stdout.write('0')
			else:
				stdout.write('1')
				idx += 1
				for j in range(idx, 2 * n):
					if s2[j] == '0':
						stdout.write('0')
					else:
						break
				idx = j
		stdout.write('\n')


import sys
input = sys.stdin.readline
outL = []
t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input().strip()
	s2 = input().strip()
	s3 = input().strip()
	c1 = 0
	c2 = 0
	c3 = 0
	l = []
	while max(c1, c2, c3) < 2 * n:
		if s1[c1] == s2[c2] == s3[c3]:
			l.append(s1[c1])
			c1 += 1
			c2 += 1
			c3 += 1
		elif s1[c1] == s2[c2]:
			l.append(s1[c1])
			c1 += 1
			c2 += 1
		elif s2[c2] == s3[c3]:
			l.append(s2[c2])
			c2 += 1
			c3 += 1
		else:
			assert s1[c1] == s3[c3]
			l.append(s1[c1])
			c1 += 1
			c3 += 1
	rem = [(-c1, 1), (-c2, 2), (-c3, 3)]
	rem.sort()
	(_, add) = rem[1]
	if add == 1:
		sn = s1
		cn = c1
	elif add == 2:
		sn = s2
		cn = c2
	else:
		sn = s3
		cn = c3
	l.append(sn[cn:])
	out = ''.join(l)
	if len(out) < 3 * n:
		out += '0' * (3 * n - len(out))
	outL.append(out)
print('\n'.join(outL))


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	if n == 1:
		return 0
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [digit[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [digit[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class Matrix:
	mod = 10 ** 9 + 7

	def set_mod(m):
		Matrix.mod = m

	def __init__(self, L):
		self.row = len(L)
		self.column = len(L[0])
		self._matrix = L
		for i in range(self.row):
			for j in range(self.column):
				self._matridigit[i][j] %= Matrix.mod

	def __getitem__(self, item):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		return self._matridigit[i][j]

	def __setitem__(self, item, val):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		self._matridigit[i][j] = val

	def __add__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matridigit[i][j] + other._matridigit[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __sub__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matridigit[i][j] - other._matridigit[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __mul__(self, other):
		if type(other) != int:
			if self.column != other.row:
				raise SizeError('sizes of matrixes are different')
			res = [[0 for j in range(other.column)] for i in range(self.row)]
			for i in range(self.row):
				for j in range(other.column):
					temp = 0
					for k in range(self.column):
						temp += self._matridigit[i][k] * other._matrix[k][j]
					res[i][j] = temp % Matrix.mod
			return Matrix(res)
		else:
			n = other
			res = [[n * self._matridigit[i][j] % Matrix.mod for j in range(self.column)] for i in range(self.row)]
			return Matrix(res)

	def __pow__(self, m):
		if self.column != self.row:
			raise MatrixPowError('the size of row must be the same as that of column')
		n = self.row
		res = Matrix([[int(i == j) for i in range(n)] for j in range(n)])
		while m:
			if m % 2 == 1:
				res = res * self
			self = self * self
			m //= 2
		return res

	def __str__(self):
		res = []
		for i in range(self.row):
			for j in range(self.column):
				res.append(str(self._matridigit[i][j]))
				res.append(' ')
			res.append('\n')
		res = res[:len(res) - 1]
		return ''.join(res)
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import gcd, log
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
for _ in range(int(input())):
	n = int(input())
	s = [input() for i in range(3)]
	most = [0 for i in range(3)]
	for i in range(3):
		if s[i].count('1') > n:
			most[i] = 1
	if most.count(0) >= 2:
		idx = [i for i in range(3) if most[i] == 0]
		(a, b) = (s[idx[0]], s[idx[1]])
		m = min(a.count('0'), b.count('0'))
		res = []
		cnt = 0
		aidx = 0
		bidx = 0
		for i in range(m):
			while aidx < 2 * n and a[aidx] == '1':
				res.append('1')
				aidx += 1
			while bidx < 2 * n and b[bidx] == '1':
				res.append('1')
				bidx += 1
			res.append('0')
			aidx += 1
			bidx += 1
		res += a[aidx:] + b[bidx:]
		print(''.join(res))
	else:
		idx = [i for i in range(3) if most[i] == 1]
		(a, b) = (s[idx[0]], s[idx[1]])
		m = min(a.count('1'), b.count('1'))
		res = []
		cnt = 0
		aidx = 0
		bidx = 0
		for i in range(m):
			while aidx < 2 * n and a[aidx] == '0':
				res.append('0')
				aidx += 1
			while bidx < 2 * n and b[bidx] == '0':
				res.append('0')
				bidx += 1
			res.append('1')
			aidx += 1
			bidx += 1
		res += a[aidx:] + b[bidx:]
		print(''.join(res))


class Fmt:

	def __init__(self):
		a = input()
		self.str = a
		self.len = len(a)
		self.cnt_0 = sum([1 for i in a if i == '0'])
		self.cnt_1 = self.len - self.cnt_0

	def __getitem__(self, item):
		return self.str[item]

def color(a, b, n):
	if a.cnt_0 >= n and b.cnt_0 >= n:
		return '0'
	if a.cnt_1 >= n and b.cnt_1 >= n:
		return '1'
	return -1

def combine(a, b, c):
	result = []
	i = 0
	j = 0
	n = a.len
	while i < n or j < n:
		if i == n:
			result.append(b[j])
			j += 1
		elif j == n:
			result.append(a[i])
			i += 1
		elif a[i] == b[j]:
			result.append(a[i])
			i += 1
			j += 1
		elif a[i] != c:
			result.append(a[i])
			i += 1
		else:
			result.append(b[j])
			j += 1
	return ''.join(result)

def run():
	n = int(input())
	S = [Fmt() for i in range(3)]
	for i in range(3):
		for j in range(3):
			if i != j and color(S[i], S[j], n) != -1:
				return combine(S[i], S[j], color(S[i], S[j], n))
test = int(input())
while test > 0:
	test -= 1
	print(run())


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	s3 = input()
	(p1, p2, p3) = (0, 0, 0)
	res = []
	while max(p1, p2, p3) < 2 * n:
		if s1[p1] == s2[p2]:
			res.append(s1[p1])
			p1 += 1
			p2 += 1
		elif s1[p1] == s3[p3]:
			res.append(s1[p1])
			p1 += 1
			p3 += 1
		else:
			res.append(s2[p2])
			p2 += 1
			p3 += 1
	rest = ''
	if p1 == 2 * n:
		if p2 >= p3:
			rest = s2[p2:]
		else:
			rest = s3[p3:]
	elif p2 == 2 * n:
		if p1 >= p3:
			rest = s1[p1:]
		else:
			rest = s3[p3:]
	elif p1 >= p2:
		rest = s1[p1:]
	else:
		rest = s2[p2:]
	print(*res, sep='', end='')
	print(rest)


import sys, math
import heapq
from collections import deque
input = sys.stdin.readline

def ip():
	return int(input())

def sp():
	return str(input().rstrip())

def mip():
	return map(int, input().split())

def msp():
	return map(str, input().split())

def lmip():
	return list(map(int, input().split()))

def lmsp():
	return list(map(str, input().split()))

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)

def isPrime(x):
	if x == 1:
		return False
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			return False
	return True

def find(x):
	if x == p[x]:
		return x
	q = find(p[x])
	p[x] = q
	return q

def union(x, y):
	global n
	x = find(x)
	y = find(y)
	if x != y:
		p[y] = x

def getPow(a, x):
	ret = 1
	while x:
		if x & 1:
			ret = ret * a % MOD
		a = a * a % MOD
		x >>= 1
	return ret

def getInv(x):
	return getPow(x, MOD - 2)

def lowerBound(start, end, key):
	while start < end:
		mid = (start + end) // 2
		if lst[mid] == key:
			end = mid
		elif key < lst[mid]:
			end = mid
		elif lst[mid] < key:
			start = mid + 1
	return end

def upperBound(start, end, key):
	while start < end:
		mid = (start + end) // 2
		if lst[mid] == key:
			start = mid + 1
		elif lst[mid] < key:
			start = mid + 1
		elif key < lst[mid]:
			end = mid
	if end == len(lst):
		return end - 1
	return end
t = ip()
while t:
	t -= 1
	n = ip()
	a = sp()
	b = sp()
	c = sp()
	(i, j, k) = (0, 0, 0)
	ans = []
	while True:
		if i == 2 * n:
			if j >= k:
				for m in range(j, 2 * n):
					ans.append(b[m])
			else:
				for m in range(k, 2 * n):
					ans.append(c[m])
			break
		elif j == 2 * n:
			if i >= k:
				for m in range(i, 2 * n):
					ans.append(a[m])
			else:
				for m in range(k, 2 * n):
					ans.append(c[m])
			break
		elif k == 2 * n:
			if j >= i:
				for m in range(j, 2 * n):
					ans.append(b[m])
			else:
				for m in range(i, 2 * n):
					ans.append(a[m])
			break
		if a[i] == b[j]:
			ans.append(a[i])
			i += 1
			j += 1
		elif b[j] == c[k]:
			ans.append(b[j])
			j += 1
			k += 1
		else:
			ans.append(a[i])
			i += 1
			k += 1
	print(*ans, sep='')


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve():
	n = int(input())
	a = input()
	b = input()
	c = input()
	median_0 = []
	median_1 = []
	for string in (a, b, c):
		popcount = string.count('1')
		if popcount <= n:
			median_0.append(string)
		if popcount >= n:
			median_1.append(string)
	if len(median_0) > 1:
		a = median_0.pop()
		b = median_0.pop()
		median = '0'
	else:
		a = median_1.pop()
		b = median_1.pop()
		median = '1'
	novel = []
	i = 0
	j = 0
	while i < 2 * n or j < 2 * n:
		if i < 2 * n and a[i] != median:
			novel.append(a[i])
			i += 1
		elif j < 2 * n and b[j] != median:
			novel.append(b[j])
			j += 1
		else:
			novel.append(median)
			if i < 2 * n:
				i += 1
			if j < 2 * n:
				j += 1
	return ''.join(novel)
t = int(input())
output = []
for _ in range(t):
	output.append(solve())
print(*output, sep='\n')


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		N = int(input())
		S = []
		for _ in range(3):
			S.append(input().rstrip('\n'))
		T0 = []
		T1 = []
		for i in range(3):
			if S[i].count('0') > N:
				T0.append(S[i])
			else:
				T1.append(S[i])
		if len(T0) >= 2:
			(U0, U1) = T0[:2]
			if U0.count('0') < U1.count('0'):
				(U0, U1) = (U1, U0)
			ans = []
			for i in range(2 * N):
				ans.append(U0[i])
			ans2 = []
			j = 0
			for u1 in U1:
				if u1 == '0':
					while True:
						ans2.append(ans[j])
						j += 1
						if ans2[-1] == '0':
							break
				else:
					ans2.append('1')
			for k in range(j, 2 * N):
				ans2.append(U0[k])
			print(''.join(ans2))
		else:
			(U0, U1) = T1[:2]
			if U0.count('1') < U1.count('1'):
				(U0, U1) = (U1, U0)
			ans = []
			for i in range(2 * N):
				ans.append(U0[i])
			ans2 = []
			j = 0
			for u1 in U1:
				if u1 == '1':
					while True:
						ans2.append(ans[j])
						j += 1
						if ans2[-1] == '1':
							break
				else:
					ans2.append('0')
			for k in range(j, 2 * N):
				ans2.append(U0[k])
			print(''.join(ans2))
main()


from sys import stdin, stdout

def count(s):
	return sum((1 for c in s if c == '1'))

def build(s1, s2, m):
	i1 = 0
	i2 = 0
	answer = ''
	while i1 < len(s1) and i2 < len(s2):
		if s1[i1] == s2[i2]:
			answer += s1[i1]
			i1 += 1
			i2 += 1
		elif s1[i1] != m:
			answer += s1[i1]
			i1 += 1
		else:
			answer += s2[i2]
			i2 += 1
	return answer + s1[i1:] + s2[i2:] + '\n'
n = int(stdin.readline())
for _ in range(n):
	k = int(stdin.readline())
	a = stdin.readline().strip()
	b = stdin.readline().strip()
	c = stdin.readline().strip()
	arr0 = []
	arr1 = []
	for s in [a, b, c]:
		if count(s) >= k:
			arr1.append(s)
		else:
			arr0.append(s)
	if len(arr0) > 1:
		stdout.write(build(arr0[0], arr0[1], '0'))
	else:
		stdout.write(build(arr1[0], arr1[1], '1'))


import sys
from sys import stdin

def solve(a, b, X):
	ans = []
	ca = [a[i] for i in range(len(a))]
	cb = [b[i] for i in range(len(b))]
	while len(ca) > 0 or len(cb) > 0:
		if len(cb) == 0:
			ans.append(ca[-1])
			del ca[-1]
		elif len(ca) == 0:
			ans.append(cb[-1])
			del cb[-1]
		elif ca[-1] == cb[-1]:
			ans.append(ca[-1])
			del ca[-1]
			del cb[-1]
		else:
			ans.append(X)
			if ca[-1] == X:
				del ca[-1]
			else:
				del cb[-1]
	while len(ans) < 3 * n:
		ans.append('0')
	ans.reverse()
	return ''.join(ans)
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	s = [stdin.readline()[:-1] for i in range(3)]
	lis = []
	for i in range(3):
		one = 0
		zero = 0
		for j in s[i]:
			if j == '0':
				zero += 1
			else:
				one += 1
		if one < zero:
			lis.append('1')
		else:
			lis.append('0')
	flag = True
	for i in range(3):
		for j in range(i):
			if lis[i] == lis[j] and flag:
				print(solve(s[i], s[j], lis[i]))
				flag = False


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solveo(a, b):
	ans = ['2'] * (3 * n)
	i = 0
	while a or b:
		if a and b and (a[-1] == b[-1]):
			ans[i] = a[-1]
			i += 1
			a.pop()
			b.pop()
		elif a and a[-1] == '1':
			while b and b[-1] == '0':
				ans[i] = '0'
				b.pop()
				i += 1
			if b and b[-1] == '1':
				ans[i] = '1'
				a.pop()
				b.pop()
				i += 1
			else:
				ans[i] = a[-1]
				i += 1
				a.pop()
		elif b and b[-1] == '1':
			while a and a[-1] == '0':
				ans[i] = '0'
				a.pop()
				i += 1
			if a and a[-1] == '1':
				ans[i] = '1'
				a.pop()
				b.pop()
				i += 1
			else:
				ans[i] = b[-1]
				i += 1
				b.pop()
		elif a:
			ans[i] = a[-1]
			a.pop()
			i += 1
		else:
			ans[i] = b[-1]
			b.pop()
			i += 1
	print(''.join(ans[:i][::-1]))

def solvez(a, b):
	ans = ['2'] * (3 * n)
	i = 0
	while a or b:
		if a and b and (a[-1] == b[-1]):
			ans[i] = a[-1]
			i += 1
			a.pop()
			b.pop()
		elif a and a[-1] == '0':
			while b and b[-1] == '1':
				ans[i] = '1'
				b.pop()
				i += 1
			if b and b[-1] == '0':
				ans[i] = '0'
				a.pop()
				b.pop()
				i += 1
			else:
				ans[i] = a[-1]
				i += 1
				a.pop()
		elif b and b[-1] == '0':
			while a and a[-1] == '1':
				ans[i] = '1'
				a.pop()
				i += 1
			if a and a[-1] == '0':
				ans[i] = '0'
				a.pop()
				b.pop()
				i += 1
			else:
				ans[i] = b[-1]
				i += 1
				b.pop()
		elif a:
			ans[i] = a[-1]
			a.pop()
			i += 1
		else:
			ans[i] = b[-1]
			b.pop()
			i += 1
	print(''.join(ans[:i][::-1]))
for _ in range(int(input())):
	n = int(input())
	a = [i for i in input()]
	b = [i for i in input()]
	c = [i for i in input()]
	o1 = a.count('1')
	z1 = 2 * n - o1
	o2 = b.count('1')
	z2 = 2 * n - o2
	o3 = c.count('1')
	z3 = 2 * n - o3
	ct = 0
	if o1 >= n:
		ct += 1
	if o2 >= n:
		ct += 1
	if o3 >= n:
		ct += 1
	if ct >= 2:
		if o1 >= n and o2 >= n:
			solveo(a, b)
		elif o1 >= n and o3 >= n:
			solveo(a, c)
		elif o2 >= n and o3 >= n:
			solveo(b, c)
	elif z1 >= n and z2 >= n:
		solvez(a, b)
	elif z1 >= n and z3 >= n:
		solvez(a, c)
	elif z2 >= n and z3 >= n:
		solvez(b, c)