You are given three sequences: $a_1, a_2, \ldots, a_n$; $b_1, b_2, \ldots, b_n$; $c_1, c_2, \ldots, c_n$.

For each $i$, $a_i \neq b_i$, $a_i \neq c_i$, $b_i \neq c_i$.

Find a sequence $p_1, p_2, \ldots, p_n$, that satisfy the following conditions:



 $p_i \in \{a_i, b_i, c_i\}$

 $p_i \neq p_{(i \mod n) + 1}$.

In other words, for each element, you need to choose one of the three possible values, such that no two adjacent elements (where we consider elements $i,i+1$ adjacent for $i<n$ and also elements $1$ and $n$) will have equal value.

It can be proved that in the given constraints solution always exists. You don't need to minimize/maximize anything, you need to find any proper sequence.


-----Input-----

The first line of input contains one integer $t$ ($1 \leq t \leq 100$): the number of test cases.

The first line of each test case contains one integer $n$ ($3 \leq n \leq 100$): the number of elements in the given sequences.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 100$).

The third line contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \leq b_i \leq 100$).

The fourth line contains $n$ integers $c_1, c_2, \ldots, c_n$ ($1 \leq c_i \leq 100$).

It is guaranteed that $a_i \neq b_i$, $a_i \neq c_i$, $b_i \neq c_i$ for all $i$.


-----Output-----

For each test case, print $n$ integers: $p_1, p_2, \ldots, p_n$ ($p_i \in \{a_i, b_i, c_i\}$, $p_i \neq p_{i \mod n + 1}$).

If there are several solutions, you can print any.


-----Example-----
Input
5
3
1 1 1
2 2 2
3 3 3
4
1 2 1 2
2 1 2 1
3 4 3 4
7
1 3 3 1 1 1 1
2 4 4 3 2 2 4
4 2 2 2 4 4 2
3
1 2 1
2 3 3
3 1 2
10
1 1 1 2 2 2 3 3 3 1
2 2 2 3 3 3 1 1 1 2
3 3 3 1 1 1 2 2 2 3

Output
1 2 3
1 2 1 2
1 3 4 3 2 4 2
1 3 2
1 2 3 1 2 3 1 2 3 2



-----Note-----

In the first test case $p = [1, 2, 3]$.

It is a correct answer, because:

  $p_1 = 1 = a_1$, $p_2 = 2 = b_2$, $p_3 = 3 = c_3$  $p_1 \neq p_2 $, $p_2 \neq p_3 $, $p_3 \neq p_1$ 

All possible correct answers to this test case are: $[1, 2, 3]$, $[1, 3, 2]$, $[2, 1, 3]$, $[2, 3, 1]$, $[3, 1, 2]$, $[3, 2, 1]$.

In the second test case $p = [1, 2, 1, 2]$.

In this sequence $p_1 = a_1$, $p_2 = a_2$, $p_3 = a_3$, $p_4 = a_4$. Also we can see, that no two adjacent elements of the sequence are equal.

In the third test case $p = [1, 3, 4, 3, 2, 4, 2]$.

In this sequence $p_1 = a_1$, $p_2 = a_2$, $p_3 = b_3$, $p_4 = b_4$, $p_5 = b_5$, $p_6 = c_6$, $p_7 = c_7$. Also we can see, that no two adjacent elements of the sequence are equal.

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms


Solutions:
from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for i in range(1, n - 1):
		if a[i] != p[-1]:
			p.append(a[i])
		elif b[i] != p[-1]:
			p.append(b[i])
	if p[-1] != a[-1] and a[-1] != p[0]:
		p.append(a[-1])
	elif p[-1] != b[-1] and b[-1] != p[0]:
		p.append(b[-1])
	else:
		p.append(c[-1])
	p = ' '.join(map(str, p))
	print(p)


for aww in range(int(input())):
	b = []
	c = int(input())
	d = []
	for i in range(3):
		a = [*map(int, input().split())]
		b.append(a)
	d.append(b[0][0])
	for i in range(1, c):
		if b[0][i] == d[i - 1] and i != c - 1:
			d.append(b[1][i])
		elif i == c - 1:
			if b[0][i] == d[0]:
				if b[1][i] == d[i - 1]:
					d.append(b[2][i])
				else:
					d.append(b[1][i])
			elif b[0][i] == d[i - 1]:
				if b[1][i] == d[0]:
					d.append(b[2][i])
				else:
					d.append(b[1][i])
			else:
				d.append(b[0][i])
		else:
			d.append(b[0][i])
	print(' '.join(map(str, d)))


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	for i in range(n - 1):
		if len(ans) == 0:
			ans += [a[i]]
		elif a[i] != ans[-1]:
			ans.append(a[i])
		elif b[i] != ans[-1]:
			ans.append(b[i])
		elif c[i] != ans[-1]:
			ans.append(c[i])
	if a[n - 1] != ans[-1] and a[n - 1] != ans[0]:
		ans.append(a[n - 1])
	elif b[n - 1] != ans[-1] and b[n - 1] != ans[0]:
		ans.append(b[n - 1])
	elif c[n - 1] != ans[-1] and c[n - 1] != ans[0]:
		ans.append(c[n - 1])
	ans = list(map(str, ans))
	print(' '.join(ans[:n]))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	out = [-1] * n
	for i in range(n):
		if a[i] != out[(i - 1) % n] and a[i] != out[(i + 1) % n]:
			out[i] = a[i]
		if b[i] != out[(i - 1) % n] and b[i] != out[(i + 1) % n]:
			out[i] = b[i]
		if c[i] != out[(i - 1) % n] and c[i] != out[(i + 1) % n]:
			out[i] = c[i]
	print(' '.join(map(str, out)))


import sys
from sys import stdin, stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
try:
	for _ in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		c = [int(i) for i in input().split()]
		ans = []
		ans.append(a[0])
		for i in range(1, n):
			tem = [a[i], b[i], c[i]]
			for j in tem:
				if j != ans[-1]:
					ans.append(j)
					break
		if ans[0] == ans[-1]:
			ans.pop()
			tem = [a[-1], b[-1], c[-1]]
			for i in tem:
				if i != ans[0] and i != ans[-1]:
					ans.append(i)
					break
			print(*ans)
		else:
			print(*ans)
except EOFError as e:
	print(e)


def func(n):
	a = list()
	b = list()
	c = list()
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	c = [int(x) for x in input().split(' ')]
	p = list()
	for i in range(n):
		if i == 0:
			p.append(a[i])
		elif i > 0 and i < n - 1:
			if p[i - 1] == a[i]:
				if p[i - 1] == b[i]:
					p.append(c[i])
				else:
					p.append(b[i])
			else:
				p.append(a[i])
		elif p[0] != a[i] and p[i - 1] != a[i]:
			p.append(a[i])
		elif p[0] != b[i] and p[i - 1] != b[i]:
			p.append(b[i])
		else:
			p.append(c[i])
	p = [str(i) for i in p]
	return ' '.join(p)
T = int(input())
for i in range(T):
	n = int(input())
	res = func(n)
	print(res)


for __ in range(int(input())):
	n = int(input())
	l = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	c1 = 0
	for i in range(n):
		if c1 == 0:
			l.append(a[i])
			d = a[i]
			e = a[i]
		elif c1 == n - 1:
			if a[i] != d and a[i] != e:
				l.append(a[i])
				d = a[i]
			elif b[i] != d and b[i] != e:
				l.append(b[i])
				d = b[i]
			elif c[i] != d and c[i] != e:
				l.append(c[i])
				d = c[i]
		elif a[i] != d:
			l.append(a[i])
			d = a[i]
		elif b[i] != d:
			l.append(b[i])
			d = b[i]
		elif c[i] != d:
			l.append(c[i])
			d = c[i]
		c1 += 1
	for i in l:
		print(i, end=' ')
	print()


R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'n,=R();r=[0]*n;i=0\nfor t in zip(R(),R(),R()):i+=1;r[i-1],*_={*t}-{r[i-2],r[i%n]}\nprint(*r)\n')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.setrecursionlimit(int(pow(10, 6)))
	sys.stdin = open('input.txt', 'r')
except:
	pass
for _ in range(L()[0]):
	n = L()[0]
	A = L()
	B = L()
	C = L()
	global x
	x = []

	def rec(i):
		global x
		if i == n:
			return True
		y = [A[i], B[i], C[i]]
		for j in range(3):
			if len(x) and y[j] == x[-1] or (len(x) and x[0] == y[j] and (i == n - 1)):
				continue
			x += [y[j]]
			if rec(i + 1):
				return True
			x.pop()
		return False
	rec(0)
	print(*x)
endtime = time.time()


for c in range(int(input())):
	i = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	ne = []
	ans = []
	for b in range(len(l1)):
		if b == 0:
			ne.append(l1[b])
		elif l1[b] != ne[b - 1] and (b + 1 < i or l1[b] != ne[0]):
			ne.append(l1[b])
		elif l2[b] != ne[b - 1] and (b + 1 < i or l2[b] != ne[0]):
			ne.append(l2[b])
		else:
			ne.append(l3[b])
	print(*ne, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [0 for _ in range(n)]
	p[0] = a[0]
	for i in range(1, n):
		p[i] = a[i]
		if p[i - 1] == a[i]:
			p[i] = b[i]
	if p[0] == p[n - 1]:
		p[0] = b[0]
	if p[0] == p[1]:
		p[0] = c[0]
	print(' '.join(map(str, p)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		elif b[i] != ans[i - 1]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	if a[n - 1] != ans[n - 2] and a[n - 1] != ans[0]:
		ans.append(a[n - 1])
	elif b[n - 1] != ans[n - 2] and b[n - 1] != ans[0]:
		ans.append(b[n - 1])
	else:
		ans.append(c[n - 1])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [None] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		if p[i - 1] != a[i]:
			p[i] = a[i]
		elif p[i - 1] != b[i]:
			p[i] = b[i]
		else:
			p[i] = c[i]
	if p[-2] != a[-1] and p[0] != a[-1]:
		p[-1] = a[-1]
	elif p[-2] != b[-1] and p[0] != b[-1]:
		p[-1] = b[-1]
	else:
		p[-1] = c[-1]
	print(' '.join(map(str, p)))


import math
t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	u = []
	u.append(str(a[0]))
	for j in range(0, n - 1):
		if j == n - 2:
			if str(a[j + 1]) != u[-1] and str(a[j + 1]) != u[0]:
				u.append(str(a[j + 1]))
			elif str(b[j + 1]) != u[-1] and str(b[j + 1]) != u[0]:
				u.append(str(b[j + 1]))
			else:
				u.append(str(c[j + 1]))
		elif str(a[j + 1]) != u[-1]:
			u.append(str(a[j + 1]))
		elif str(b[j + 1]) != u[-1]:
			u.append(str(b[j + 1]))
		else:
			u.append(str(c[j + 1]))
	print(' '.join(u))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	res = []
	last = -1
	for i in range(n):
		if i == n - 1:
			if A[i] != last and A[i] != int(res[0]):
				res.append(str(A[i]))
				last = A[i]
			elif B[i] != last and B[i] != int(res[0]):
				res.append(str(B[i]))
				last = B[i]
			else:
				res.append(str(C[i]))
				last = C[i]
		elif A[i] != last:
			res.append(str(A[i]))
			last = A[i]
		elif B[i] != last:
			res.append(str(B[i]))
			last = B[i]
		else:
			res.append(str(C[i]))
			last = C[i]
	print(' '.join(res))


import sys
import random
from fractions import Fraction
from math import *

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

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return list(map(int, tinput()))

def fiinput():
	return list(map(float, tinput()))

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

def trinput():
	return tuple(rinput())

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

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	q = [rlinput(), rlinput(), rlinput()]
	ans = q[0].copy()
	for i in range(1, n):
		if ans[i] == ans[i - 1]:
			ans[i] = q[1][i]
		if i == n - 1:
			o = 0
			while q[o][i] == ans[n - 2] or q[o][i] == ans[0]:
				o += 1
			ans[i] = q[o][i]
	print(*ans)
for i in range(iinput()):
	main()


import re
from string import ascii_lowercase
from math import inf, ceil, factorial, log
from collections import defaultdict, deque, Counter
from bisect import bisect, insort, bisect_left, bisect_right
mod = int(1000000000.0) + 7

def is_valid(arr):
	brr = arr + arr
	return all((brr[i] != brr[i - 1] for i in range(1, len(brr))))

def solve():
	n = int(input())
	grid = [list(map(int, input().split())) for i in range(3)]
	for i in range(3):
		arr = [grid[i][0]]
		for j in range(1, n):
			for k in range(3):
				if grid[k][j] != arr[-1]:
					arr.append(grid[k][j])
					break
		if len(arr) == n and is_valid(arr):
			print(*arr)
			break

def main():
	for _ in range(int(input())):
		solve()
main()


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')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

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

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = a[0]
	for i in range(1, n - 1):
		ans[i] = a[i] if a[i] != ans[i - 1] else b[i]
	if 1:
		l = [a[-1], b[-1], c[-1]]
		try:
			l.remove(ans[-2])
		except:
			pass
		try:
			l.remove(ans[0])
		except:
			pass
		ans[-1] = l[0]
	print(*ans)


def diferitde(v, u):

	def ok(x):
		i = 0
		while i < len(v) and v[i] != x:
			i += 1
		return i >= len(v)
	for i in range(len(u)):
		if ok(u[i]):
			return u[i]
	return -1
rd = lambda : list(map(int, input().split()))
for t in range(int(input())):
	n = int(input())
	(a, b, c) = (rd(), rd(), rd())
	sol = []
	sol.append(a[0])
	for i in range(1, n - 1):
		sol.append(diferitde([sol[-1]], [a[i], b[i], c[i]]))
	sol.append(diferitde([sol[-1], sol[0]], [a[n - 1], b[n - 1], c[n - 1]]))
	print(*sol)


t = int(input())
for i in range(t):
	n = int(input())
	a1 = input().split()
	a2 = input().split()
	a3 = input().split()
	w = []
	for j in range(n):
		if len(w) == 0:
			w.append(a1[j])
		elif len(w) == n - 1:
			if a1[j] != w[j - 1] and a1[j] != w[0]:
				w.append(a1[j])
			elif a2[j] != w[j - 1] and a2[j] != w[0]:
				w.append(a2[j])
			elif a3[j] != w[j - 1] and a3[j] != w[0]:
				w.append(a3[j])
		elif a1[j] != w[j - 1]:
			w.append(a1[j])
		elif a2[j] != w[j - 1]:
			w.append(a2[j])
		elif a3[j] != w[j - 1]:
			w.append(a3[j])
	for i in w:
		print(i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	prev = -1
	for i in range(n):
		if i == n - 1:
			if a[i] != prev and a[i] != first:
				print(a[i], end=' ')
				prev = a[i]
			elif b[i] != prev and b[i] != first:
				print(b[i], end=' ')
				prev = b[i]
			else:
				print(c[i], end=' ')
				prev = c[i]
		else:
			if a[i] != prev:
				print(a[i], end=' ')
				prev = a[i]
			elif b[i] != prev:
				print(b[i], end=' ')
				prev = b[i]
			else:
				print(c[i], end=' ')
				prev = c[i]
			if i == 0:
				first = prev
	print()


n = int(input())
for i in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for i in range(1, t - 1):
		if a[i] != p[i - 1]:
			p.append(a[i])
		elif b[i] != p[i - 1]:
			p.append(b[i])
		else:
			p.append(c[i])
	if a[t - 1] != p[0] and a[t - 1] != p[t - 2]:
		p.append(a[t - 1])
	elif b[t - 1] != p[0] and b[t - 1] != p[t - 2]:
		p.append(b[t - 1])
	else:
		p.append(c[t - 1])
	print(*p, sep=' ')


r = lambda : [*map(int, input().split())]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = [a[0]]
	for i in range(1, n - 1):
		if a[i] != l[i - 1]:
			l.append(a[i])
		elif b[i] != l[i - 1]:
			l.append(b[i])
	if a[-1] != l[-1] and a[-1] != l[0]:
		l.append(a[-1])
	elif b[-1] != l[-1] and b[-1] != l[0]:
		l.append(b[-1])
	elif c[-1] != l[-1] and c[-1] != l[0]:
		l.append(c[-1])
	print(*l)


cases = int(input())

def find_p(a, b, c, p, last):
	global FOUND
	if FOUND:
		return
	if len(a) == 0:
		if p[0] != p[-1]:
			global global_p
			FOUND = True
			global_p = p
	else:
		a_i = a.pop(0)
		b_i = b.pop(0)
		c_i = c.pop(0)
		p_a = p + [a_i]
		p_b = p + [b_i]
		p_c = p + [c_i]
		if last != a_i:
			find_p(a, b, c, p_a, a_i)
		if last != b_i:
			find_p(a, b, c, p_b, b_i)
		if last != c_i:
			find_p(a, b, c, p_c, c_i)
for i in range(cases):
	FOUND = False
	global_p = []
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	c = [int(x) for x in input().split(' ')]
	find_p(a, b, c, [], None)
	global_p = [str(x) for x in global_p]
	print(' '.join(global_p))


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	c = [int(i) for i in input().split(' ')]
	p = [0 for i in range(n)]
	p[0] = a[0]
	res = str(a[0]) + ' '
	for i in range(1, n - 1):
		if a[i] == p[i - 1]:
			p[i] = b[i]
		else:
			p[i] = a[i]
		res = res + str(p[i]) + ' '
	l = [p[0], p[n - 2]]
	if not a[-1] in l:
		p[-1] = a[-1]
	if not b[-1] in l:
		p[-1] = b[-1]
	if not c[-1] in l:
		p[-1] = c[-1]
	res = res + str(p[-1]) + ' '
	print(res)


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li
INF = 1000000000.0
primes = SieveOfEratosthenes(1300000)

def fn(n):
	i = 2
	res = n - 1
	val = 0
	for i in range(int(sqrt(n)) + 1, 1, -1):
		val = i - 1 + int(ceil((n - i) / i))
		if val <= res:
			res = val
		else:
			break
	return res
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n):
		if i != n - 1:
			if a[i] == ans[-1]:
				if b[i] == ans[-1]:
					temp = c
				else:
					temp = b
			else:
				temp = a
		elif a[i] == ans[0] or a[i] == ans[-1]:
			if b[i] == ans[0] or b[i] == ans[-1]:
				temp = c
			else:
				temp = b
		else:
			temp = a
		ans.append(temp[i])
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	c = list(map(str, input().split()))
	l = [a[0]]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != l[i - 1]:
				l.append(a[i])
			elif b[i] != l[i - 1]:
				l.append(b[i])
			else:
				l.append(c[i])
		elif a[i] != l[i - 1] and a[i] != l[0]:
			l.append(a[i])
		elif b[i] != l[i - 1] and b[i] != l[0]:
			l.append(b[i])
		else:
			l.append(c[i])
	print(' '.join(l))


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 * 2

def solve():
	n = II()
	a = L()
	b = L()
	c = L()
	p = [0] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p[i] = a[i]
		elif b[i] != p[i - 1]:
			p[i] = b[i]
		else:
			p[i] = c[i]
	if a[n - 1] != p[n - 2] and a[n - 1] != p[0]:
		p[n - 1] = a[n - 1]
	elif b[n - 1] != p[n - 2] and b[n - 1] != p[0]:
		p[n - 1] = b[n - 1]
	else:
		p[n - 1] = c[n - 1]
	print(*p)
	return
t = II()
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = [a[0]] * n
	for j in range(1, n - 1):
		if p[j - 1] != a[j]:
			p[j] = a[j]
		elif p[j - 1] != b[j]:
			p[j] = b[j]
		elif p[j - 1] != c[j]:
			p[j] = c[j]
	if p[n - 2] != a[n - 1] and p[0] != a[n - 1]:
		p[n - 1] = a[n - 1]
	elif p[n - 2] != b[n - 1] and p[0] != b[n - 1]:
		p[n - 1] = b[n - 1]
	elif p[n - 2] != c[n - 1] and p[0] != c[n - 1]:
		p[n - 1] = c[n - 1]
	print(*p)


t = int(input())
for i in range(t):
	s = []
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	m = 0
	for i in range(n):
		if i == 0:
			m = min(a[i], b[i], c[i])
			s.append(m)
		elif i == n - 1:
			if a[i] != s[-1] and a[i] != s[0]:
				s.append(a[i])
			elif b[i] != s[-1] and b[i] != s[0]:
				s.append(b[i])
			elif c[i] != s[-1] and c[i] != s[0]:
				s.append(c[i])
		elif a[i] != s[-1]:
			s.append(a[i])
		elif b[i] != s[-1]:
			s.append(b[i])
		elif c[i] != s[-1]:
			s.append(c[i])
	print(*s)


t = int(input())
test_cases = []
for i in range(t):
	case = []
	n = int(input())
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	c = list(map(str, input().split()))
	case.append(n)
	case.append(a)
	case.append(b)
	case.append(c)
	test_cases.append(case)
for case in test_cases:
	n = case[0]
	a = case[1]
	b = case[2]
	c = case[3]
	ans = []
	ans.append(a[0])
	for i in range(1, n):
		if i != n - 1:
			if a[i] != ans[i - 1]:
				ans.append(a[i])
				continue
			elif b[i] != ans[i - 1]:
				ans.append(b[i])
				continue
			elif c[i] != ans[i - 1]:
				ans.append(c[i])
				continue
		if i == n - 1:
			if a[i] != ans[i - 1] and a[i] != ans[0]:
				ans.append(a[i])
				continue
			elif b[i] != ans[i - 1] and b[i] != ans[0]:
				ans.append(b[i])
				continue
			elif c[i] != ans[i - 1] and c[i] != ans[0]:
				ans.append(c[i])
				continue
	print(' '.join(ans))


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	last = a[0]
	for j in range(1, n - 1):
		if b[j] != last:
			ans.append(b[j])
			last = b[j]
		elif c[j] != last:
			ans.append(c[j])
			last = c[j]
		else:
			ans.append(a[j])
			last = a[j]
	if c[n - 1] not in (ans[0], ans[n - 2]):
		ans.append(c[n - 1])
	elif b[n - 1] not in (ans[0], ans[n - 2]):
		ans.append(b[n - 1])
	elif a[n - 1] not in (ans[0], ans[n - 2]):
		ans.append(a[n - 1])
	print(*ans)


import sys

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

def ri():
	return int(sys.stdin.readline())

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	n = ri()
	(a, b, c) = (ria(), ria(), ria())
	l = []
	z = 0
	l.append(a[0])
	for i in range(1, n):
		if i == n - 1:
			if a[i] != l[-1] and a[i] != l[0]:
				l.append(a[i])
			elif b[i] != l[-1] and b[i] != l[0]:
				l.append(b[i])
			elif c[i] != l[-1] and c[i] != l[0]:
				l.append(c[i])
		elif a[i] != l[-1]:
			l.append(a[i])
		elif b[i] != l[-1]:
			l.append(b[i])
		elif c[i] != l[-1]:
			l.append(c[i])
	wia(l)


for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	(*c,) = map(int, input().split())
	res = [a[0]]
	for i in range(1, n - 1):
		for d in (a[i], b[i], c[i]):
			if d != res[-1]:
				res.append(d)
				break
	if n > 1:
		for d in (a[-1], b[-1], c[-1]):
			if d != res[0] and d != res[-1]:
				res.append(d)
				break
	print(*res)


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase
from math import ceil

def main():
	for i in range(int(input())):
		n = int(input())
		a = [int(X) for X in input().split()]
		b = [int(X) for X in input().split()]
		c = [int(x) for x in input().split()]
		x = [a[0]]
		for j in range(1, n - 1):
			if a[j] != x[-1]:
				x.append(a[j])
			elif b[j] != x[-1]:
				x.append(b[j])
			elif c[j] != x[-1]:
				x.append(c[j])
		if a[n - 1] != x[-1] and a[n - 1] != x[0]:
			x.append(a[n - 1])
		elif b[n - 1] != x[-1] and b[n - 1] != x[0]:
			x.append(b[n - 1])
		elif c[n - 1] != x[-1] and c[n - 1] != x[0]:
			x.append(c[n - 1])
		print(*x)
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()


for tt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	s = []
	for i in range(n - 1):
		if len(s) > 0 and a[i] != s[i - 1]:
			s.append(a[i])
		else:
			s.append(b[i])
	if c[n - 1] != s[n - 2] and c[n - 1] != s[0]:
		s.append(c[n - 1])
	elif b[n - 1] != s[n - 2] and b[n - 1] != s[0]:
		s.append(b[n - 1])
	else:
		s.append(a[n - 1])
	ans = ''
	for i in range(n):
		ans += str(s[i]) + ' '
	print(ans[:-1])


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	prev = -1
	for j in range(n - 1):
		if prev != l1[j]:
			print(l1[j], end=' ')
			prev = l1[j]
		elif prev != l1[j]:
			print(l2[j], end=' ')
			prev = l2[j]
		else:
			print(l3[j], end=' ')
			prev = l3[j]
	if l1[n - 1] != l1[0] and l1[-1] != prev:
		print(l1[-1], end=' ')
	elif l2[n - 1] != l1[0] and prev != l2[-1]:
		print(l2[-1], end=' ')
	else:
		print(l3[-1], end=' ')
	print()


def is_valid_move(valid, curr_move, n):
	if len(valid) == 0:
		return True
	elif len(valid) == n - 1:
		return valid[-1] != curr_move != valid[0]
	else:
		return valid[-1] != curr_move

def solve(valid, n, nums, i):
	if i == n:
		return True
	for j in range(3):
		if is_valid_move(valid, nums[j][i], n):
			valid.append(nums[j][i])
			if solve(valid, n, nums, i + 1) == True:
				return True
	valid.pop()
	return False
t = int(input())
for i in range(t):
	n = int(input())
	nums = []
	for j in range(3):
		temp = [int(x) for x in input().split()]
		nums.append(temp)
	valid = []
	solve(valid, n, nums, 0)
	print(*valid)


for i in range(int(input())):
	lst = list()
	lst1 = list()
	lst2 = list()
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = a
	for i in range(1, n):
		if l[i] == l[i - 1]:
			l[i] = b[i]
	if l[-1] == l[0]:
		if l[1] != c[0]:
			l[0] = c[0]
			print(*l, sep=' ')
		else:
			l[0] = b[0]
			print(*l, sep=' ')
	else:
		print(*l, sep=' ')


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	sol = []
	sol.append(a[0])
	j = 1
	while j < n:
		if sol[j - 1] != a[j % n]:
			sol.append(a[j])
		elif sol[j - 1] != b[j % n]:
			sol.append(b[j])
		elif sol[j - 1] != c[j % n]:
			sol.append(c[j])
		j += 1
	booli = 1
	for j in range(n):
		if sol[j] == sol[(j + 1) % n]:
			booli = 0
			break
	if booli:
		print(' '.join(list(map(str, sol))))
	else:
		sol = []
		sol.append(b[0])
		j = 1
		while j < n:
			if sol[j - 1] != a[j % n]:
				sol.append(a[j])
			elif sol[j - 1] != b[j % n]:
				sol.append(b[j])
			elif sol[j - 1] != c[j % n]:
				sol.append(c[j])
			j += 1
		booli = 1
		for j in range(n):
			if sol[j] == sol[(j + 1) % n]:
				booli = 0
				break
		if booli:
			print(' '.join(list(map(str, sol))))
		else:
			sol = []
			sol.append(c[0])
			j = 1
			while j < n:
				if sol[j - 1] != a[j % n]:
					sol.append(a[j])
				elif sol[j - 1] != b[j % n]:
					sol.append(b[j])
				elif sol[j - 1] != c[j % n]:
					sol.append(c[j])
				j += 1
			booli = 1
			for j in range(n):
				if sol[j] == sol[(j + 1) % n]:
					booli = 0
					break
			print(' '.join(list(map(str, sol))))
	i += 1


def solve(a, b, c):
	ans = [a[0]]
	for i in range(1, len(a)):
		if i == len(a) - 1:
			if ans[-1] != a[i] and ans[0] != a[i]:
				ans.append(a[i])
			elif ans[-1] != b[i] and ans[0] != b[i]:
				ans.append(b[i])
			else:
				ans.append(c[i])
			break
		if a[i] == ans[-1]:
			ans.append(b[i])
		else:
			ans.append(a[i])
	return ans
for i in range(int(input())):
	input()
	a = input().split()
	b = input().split()
	c = input().split()
	print(' '.join(solve(a, b, c)))


for o in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	c = list(map(str, input().split()))
	for i in range(n):
		if a[i] == a[i - 1]:
			if b[i] != a[i - 1]:
				a[i] = b[i]
			else:
				a[i] = c[i]
	if a[n - 1] == a[0]:
		if b[n - 1] != a[0]:
			a[n - 1] = b[n - 1]
		else:
			a[n - 1] = c[n - 1]
	print(' '.join(a))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	arr = [0] * n
	for i in range(n):
		if i == 0:
			arr[i] = a[i]
		elif i == n - 1:
			if arr[i - 1] != a[i] and arr[0] != a[i]:
				arr[i] = a[i]
			elif arr[i - 1] != b[i] and arr[0] != b[i]:
				arr[i] = b[i]
			elif arr[i - 1] != c[i] and arr[0] != c[i]:
				arr[i] = c[i]
		elif arr[i - 1] != a[i]:
			arr[i] = a[i]
		elif arr[i - 1] != b[i]:
			arr[i] = b[i]
		elif arr[i - 1] != c[i]:
			arr[i] = c[i]
	print(*arr)


inp = lambda : int(input())
seq = lambda : list(map(int, input().strip().split()))

def results(a, b, c, n):
	temp = [a[0]]
	for i in range(1, n - 1):
		if a[i] != temp[i - 1]:
			temp.append(a[i])
		elif b[i] != temp[i - 1]:
			temp.append(b[i])
		else:
			temp.append(c[i])
	if a[n - 1] != temp[0] and a[n - 1] != temp[-1]:
		temp.append(a[n - 1])
	elif b[n - 1] != temp[0] and b[n - 1] != temp[-1]:
		temp.append(b[n - 1])
	else:
		temp.append(c[n - 1])
	return temp

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = seq()
		b = seq()
		c = seq()
		result = results(a, b, c, n)
		print(*result)
main()


for _ in range(int(input())):
	N = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	D = [0] * N
	D[0] = A[0]
	for i in range(1, N):
		if i < N - 1:
			if A[i] != D[i - 1]:
				D[i] = A[i]
			elif B[i] != D[i - 1]:
				D[i] = B[i]
			elif C[i] != D[i - 1]:
				D[i] = C[i]
		if i == N - 1:
			if A[i] != D[0] and A[i] != D[i - 1]:
				D[i] = A[i]
			elif B[i] != D[0] and B[i] != D[i - 1]:
				D[i] = B[i]
			elif C[i] != D[0] and C[i] != D[i - 1]:
				D[i] = C[i]
	print(*D)


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for jj in range(1, n - 1):
		if ans[-1] != a[jj]:
			ans.append(a[jj])
		elif ans[-1] != b[jj]:
			ans.append(b[jj])
		else:
			ans.append(c[jj])
	if ans[-1] != a[n - 1] and ans[0] != a[n - 1]:
		ans.append(a[n - 1])
	elif ans[-1] != b[n - 1] and ans[0] != b[n - 1]:
		ans.append(b[n - 1])
	else:
		ans.append(c[n - 1])
	print(*ans)


T = int(input())
while T > 0:
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	res = []
	for i in range(n):
		if len(res) == 0 or res[-1] != arr1[i]:
			res.append(arr1[i])
		else:
			res.append(arr2[i])
	if res[-1] == res[0]:
		res.pop()
		if arr1[-1] != res[-1] and arr1[-1] != res[0]:
			res.append(arr1[-1])
		elif arr2[-1] != res[-1] and arr2[-1] != res[0]:
			res.append(arr2[-1])
		else:
			res.append(arr3[-1])
	print(*res)
	T -= 1


for i in range(int(input())):
	n = int(input())
	a1 = [int(i) for i in input().split()]
	a2 = [int(i) for i in input().split()]
	a3 = [int(i) for i in input().split()]
	ans = [a1[0]]
	for i in range(1, n):
		if a1[i] != ans[i - 1]:
			ans.append(a1[i])
		elif a2[i] != ans[i - 1]:
			ans.append(a2[i])
		elif a3[i] != ans[i - 1]:
			ans.append(a3[i])
	if ans[0] == ans[-1]:
		y = 0
		x = [a1[-1], a2[-1], a3[-1]]
		for i in x:
			if i != ans[-2] and i != ans[0] and (i != ans[-1]):
				y = i
				break
		ans = ans[:-1]
		ans.append(y)
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	good = [a[0]]
	for i in range(1, n):
		if a[i] != good[i - 1]:
			good.append(a[i])
		elif b[i] != good[i - 1]:
			good.append(b[i])
		elif c[i] != good[i - 1]:
			good.append(c[i])
	if good[-1] == good[0]:
		if a[-1] != good[0] and a[-1] != good[-2]:
			good[-1] = a[-1]
		elif b[-1] != good[0] and b[-1] != good[-2]:
			good[-1] = b[-1]
		elif c[-1] != good[0] and c[-1] != good[-2]:
			good[-1] = c[-1]
	print(*good)


t = int(input())
for _ in range(t):
	p = [0]
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	for (i, j, k) in zip(a, b, c):
		for l in [i, j, k]:
			if p[-1] != l:
				p.append(l)
				break
	if p[1] == p[-1]:
		for l in [i, j, k]:
			if p[-2] != l and p[1] != l:
				p[-1] = l
				break
	print(*p[1:])


import math
t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	l = []
	for i in range(n):
		if i == 0:
			l.append(a[i])
		elif i == n - 1:
			if l[0] != a[i] and l[i - 1] != a[i]:
				l.append(a[i])
			elif l[0] != b[i] and l[i - 1] != b[i]:
				l.append(b[i])
			elif l[0] != c[i] and l[i - 1] != c[i]:
				l.append(c[i])
		elif l[i - 1] != a[i]:
			l.append(a[i])
		elif l[i - 1] != b[i]:
			l.append(b[i])
		elif l[i - 1] != c[i]:
			l.append(c[i])
	print(*l)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	nn = n - 1
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	ans = [0] * n
	ans[nn] = l1[nn]
	for i in range(nn - 1, 0, -1):
		if l1[i] != ans[i + 1]:
			ans[i] = l1[i]
		elif l2[i] != ans[i + 1]:
			ans[i] = l2[i]
		else:
			ans[i] = l3[i]
	if l1[0] != ans[nn] and l1[0] != ans[1]:
		ans[0] = l1[0]
	elif l2[0] != ans[nn] and l2[0] != ans[1]:
		ans[0] = l2[0]
	else:
		ans[0] = l3[0]
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	for i in range(n):
		if i == 0:
			p = [a[0]]
		elif i == n - 1:
			for j in [a[i], b[i], c[i]]:
				if j != p[-1] and j != p[0]:
					p.append(j)
					break
		else:
			for j in [a[i], b[i], c[i]]:
				if j != p[-1]:
					p.append(j)
					break
	print(*p)


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split(' ')))
	list2 = list(map(int, input().split(' ')))
	list3 = list(map(int, input().split(' ')))
	list1_copy = list1.copy()
	for i in range(1, n):
		if list1[i] == list1[i - 1]:
			if list2[i] == list1[i - 1]:
				list1[i:n] = list3[i:n]
			else:
				list1[i:n] = list2[i:n]
		if i == n - 1 and list1[0] == list1[n - 1]:
			if list1_copy[n - 1] != list1[n - 1] and list1_copy[n - 1] != list1[n - 2]:
				list1[n - 1] = list1_copy[n - 1]
			elif list2[n - 1] != list1[n - 1] and list2[n - 1] != list1[n - 2]:
				list1[n - 1] = list2[n - 1]
			elif list3[n - 1] != list1[n - 1] and list3[n - 1] != list1[n - 2]:
				list1[n - 1] = list3[n - 1]
	print(' '.join((str(i) for i in list1)))


rn = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rns = lambda : map(int, input().split())
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
for _ in range(rn()):
	n = int(input())
	a = rl()
	b = rl()
	c = rl()
	ans = []
	ans.append(a[0])
	for i in range(1, n - 1):
		d = [a[i], b[i], c[i]]
		for i in d:
			if i != ans[-1]:
				ans.append(i)
				break
	d = [a[-1], b[-1], c[-1]]
	for i in d:
		if i != ans[-1] and i != ans[0] and (n > 1):
			ans.append(i)
			break
	print(' '.join(list(map(str, ans))))


def readis():
	return map(int, input().strip().split())
T = int(input())
while T:
	T -= 1
	n = int(input())
	A = readis()
	B = readis()
	C = readis()
	sol = []
	for (i, (a, b, c)) in enumerate(zip(A, B, C)):
		if not sol:
			sol.append(a)
			continue
		if a != sol[-1]:
			sol.append(a)
		else:
			sol.append(b)
		if i == n - 1:
			if sol[-1] == sol[0]:
				if sol[0] == a:
					if sol[-2] != b:
						sol[-1] = b
					else:
						sol[-1] = c
				else:
					sol[-1] = c
	assert len(sol) == n
	print(' '.join(map(str, sol)))


def circle_color(a, b, c):
	l = []
	l.append(a[0])
	for i in range(len(a) - 1):
		if i == len(a) - 2:
			if l[i] != a[i + 1] and a[i + 1] != l[0]:
				l.append(a[i + 1])
			elif l[i] != b[i + 1] and b[i + 1] != l[0]:
				l.append(b[i + 1])
			elif l[i] != c[i + 1] and c[i + 1] != l[0]:
				l.append(c[i + 1])
		elif l[i] == a[i + 1]:
			if l[i] == b[i + 1]:
				l.append(c[i + 1])
			else:
				l.append(b[i + 1])
		else:
			l.append(a[i + 1])
	return l
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	result = circle_color(a, b, c)
	print(*result, sep=' ')


def process():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(a[0])
		elif i < n - 1:
			if a[i] != ans[-1]:
				ans.append(a[i])
			elif b[i] != ans[-1]:
				ans.append(b[i])
			elif c[i] != ans[-1]:
				ans.append(c[i])
		elif a[i] != ans[-1] and a[i] != ans[0]:
			ans.append(a[i])
		elif b[i] != ans[-1] and b[i] != ans[0]:
			ans.append(b[i])
		elif c[i] != ans[-1] and c[i] != ans[0]:
			ans.append(c[i])
	ans = [str(i) for i in ans]
	print(' '.join(ans))
tests = int(input())
for i in range(tests):
	process()


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

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

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	b = lis()
	c = lis()
	r = [a[0]]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != r[0] and a[i] != r[-1]:
				r.append(a[i])
				continue
			if b[i] != r[0] and b[i] != r[-1]:
				r.append(b[i])
				continue
			if c[i] != r[0] and c[i] != r[-1]:
				r.append(c[i])
				continue
		if a[i] != r[-1]:
			r.append(a[i])
			continue
		if b[i] != r[-1]:
			r.append(b[i])
			continue
		if c[i] != r[-1]:
			r.append(c[i])
			continue
	print(*r)


import re
t = int(input())
while t:
	n = int(input())
	a = input()
	b = input()
	c = input()
	a = a.split()
	b = b.split()
	c = c.split()
	li = []
	for i in range(0, n):
		x = [a[i], b[i], c[i]]
		li.append(x)
	p = [a[0]]
	for i in range(1, n):
		for j in li[i]:
			if j != p[i - 1]:
				p.append(j)
				break
	if p[0] == p[n - 1]:
		for i in li[n - 1]:
			if i != p[0] and i != p[n - 2]:
				p[n - 1] = i
	p = ' '.join(p)
	print(p)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	z = list(map(int, input().split()))
	last = [-1]
	val = []
	p = list(zip(x, y, z))
	for i in range(n):
		u = p[i]
		for j in u:
			if j != last[-1]:
				val.append(j)
				last.append(j)
				break
	if val[0] == val[n - 1]:
		c = p[-1]
		for j in c:
			if j != val[0] and j != val[n - 2]:
				val[n - 1] = j
				break
	print(' '.join((str(i) for i in val)))


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = [a[0]]
	for i in range(1, n):
		if b[i] != l[i - 1]:
			l.append(b[i])
		elif a[i] != l[i - 1]:
			l.append(a[i])
		else:
			l.append(c[i])
	(x, y, z) = (a[-1], b[-1], c[-1])
	if l[-1] == l[0]:
		if x != l[0] and x != l[-2]:
			l[-1] = x
		elif y != l[0] and y != l[-2]:
			l[-1] = y
		else:
			l[-1] = z
	print(*l)


for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = [a[0]]
	for i in range(1, n):
		j = i - 1
		if i == n - 1:
			j = 0
		if a[i] != res[j] and a[i] != res[i - 1]:
			res.append(a[i])
		elif b[i] != res[j] and b[i] != res[i - 1]:
			res.append(b[i])
		else:
			res.append(c[i])
	print(*res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	i = 1
	j = 0
	fin = [a[0]]
	while i < n:
		if a[i] != fin[-1]:
			fin.append(a[i])
		elif b[i] != fin[-1]:
			fin.append(b[i])
		else:
			fin.append(c[i])
		i += 1
	if fin[0] == fin[n - 1]:
		if b[n - 1] != fin[0] and fin[n - 2] != b[n - 1]:
			fin[n - 1] = b[n - 1]
		elif c[n - 1] != fin[0] and fin[n - 2] != c[n - 1]:
			fin[n - 1] = c[n - 1]
		elif a[n - 1] != fin[0] and fin[n - 2] != a[n - 1]:
			fin[n - 1] = a[n - 1]
		elif fin[n - 1] != b[0] and b[0] != fin[1]:
			fin[0] = b[0]
		elif fin[n - 1] != a[0] and a[0] != fin[1]:
			fin[0] = a[0]
		elif fin[n - 1] != c[0] and c[0] != fin[1]:
			fin[0] = c[0]
	for i in fin:
		print(i, end=' ')
	print()


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	B = list(map(int, readline().split()))
	C = list(map(int, readline().split()))
	res = [A[0]]
	for i in range(1, N - 1):
		(a, b) = (A[i], B[i])
		if res[-1] != a:
			res.append(a)
		else:
			res.append(b)
	abc = [A[-1], B[-1], C[-1]]
	if res[0] in abc:
		abc.remove(res[0])
	if res[-1] in abc:
		abc.remove(res[-1])
	res.append(abc.pop())
	Ans[qu] = ' '.join(map(str, res))
print('\n'.join(Ans))


for t in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	(*c,) = map(int, input().split())
	ans = [0] * n
	ans[-1] = a[-1]
	for i in range(n - 1):
		for v in [a[i], b[i], c[i]]:
			if v != ans[i - 1] and v != ans[i + 1]:
				ans[i] = v
				break
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	L = []
	a = 0
	for i in range(n - 1):
		if A[i] != a:
			L.append(A[i])
			a = A[i]
		else:
			L.append(B[i])
			a = B[i]
	if A[n - 1] != a and A[n - 1] != L[0]:
		L.append(A[n - 1])
	elif B[n - 1] != a and B[n - 1] != L[0]:
		L.append(B[n - 1])
	else:
		L.append(C[n - 1])
	for i in L:
		print(i, end=' ')
	print()


t = int(input(''))
for i in range(t):
	n = int(input(''))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	sol = [0] * n
	sol[0] = a[0]
	for i in range(1, n):
		if a[i] != sol[i - 1]:
			sol[i] = a[i]
		elif b[i] != sol[i - 1]:
			sol[i] = b[i]
		else:
			sol[i] = c[i]
	if sol[0] == sol[n - 1]:
		if a[i] != sol[0] and a[i] != sol[n - 2]:
			sol[i] = a[i]
		elif b[i] != sol[0] and b[i] != sol[n - 2]:
			sol[i] = b[i]
		else:
			sol[i] = c[i]
	print(*sol)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for i in range(stdint()):
	n = stdint()
	a = list(stdarr())
	b = list(stdarr())
	c = list(stdarr())
	res = []
	res.append(a[0])
	for i in range(1, n):
		if i == n - 1:
			if a[i] != res[0] and a[i] != res[-1]:
				res.append(a[i])
			elif b[i] != res[0] and b[i] != res[-1]:
				res.append(b[i])
			elif c[i] != res[0] and c[i] != res[-1]:
				res.append(c[i])
		elif a[i] != res[-1]:
			res.append(a[i])
		elif b[i] != res[-1]:
			res.append(b[i])
		else:
			res.append(c[i])
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()[:n]]
	b = [int(y) for y in input().split()[:n]]
	c = [int(z) for z in input().split()[:n]]
	d = []
	for j in range(n):
		if j == 0:
			d.append(a[j])
		elif j == n - 1:
			if d[j - 1] != a[j] and a[j] != d[0]:
				d.append(a[j])
			elif d[j - 1] != b[j] and b[j] != d[0]:
				d.append(b[j])
			else:
				d.append(c[j])
		elif a[j] != d[j - 1]:
			d.append(a[j])
		elif b[j] != d[j - 1]:
			d.append(b[j])
		elif c[j] != d[j - 1]:
			d.append(c[j])
	for l in range(len(d)):
		if l == len(d) - 1:
			print(d[l])
		else:
			print(d[l], end=' ')


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().split()]
	B = [int(a) for a in input().split()]
	C = [int(a) for a in input().split()]
	ANS = []
	prev = -1
	for (a, b, c) in zip(A, B, C):
		x = b if a == prev else a
		ANS.append(x)
		prev = x
	if ANS[-2] != A[-1] != ANS[0]:
		ANS[-1] = A[-1]
	elif ANS[-2] != B[-1] != ANS[0]:
		ANS[-1] = B[-1]
	else:
		ANS[-1] = C[-1]
	print(*ANS)


for x in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for x in range(1, n - 1):
		if p[x - 1] != a[x]:
			p.append(a[x])
		elif p[x - 1] != b[x]:
			p.append(b[x])
		else:
			p.append(c[x])
	if p[0] != a[-1] and p[-1] != a[-1]:
		p.append(a[-1])
	elif p[0] != b[-1] and p[-1] != b[-1]:
		p.append(b[-1])
	else:
		p.append(c[-1])
	s = [str(i) for i in p]
	res = ' '.join(s)
	print(res)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = []
	for i in range(n):
		if i == 0:
			res.append(a[i])
		elif i == n - 1:
			if a[i] != res[-1] and a[i] != res[0]:
				res.append(a[i])
			elif b[i] != res[-1] and b[i] != res[0]:
				res.append(b[i])
			elif c[i] != res[-1] and c[i] != res[0]:
				res.append(c[i])
		elif a[i] != res[-1]:
			res.append(a[i])
		elif b[i] != res[-1]:
			res.append(b[i])
		elif c[i] != res[-1]:
			res.append(c[i])
	print(*res)


t = int(input())
for i in range(0, t):
	m = int(input())
	arr = list(map(int, input().strip().split()))[:m]
	brr = list(map(int, input().strip().split()))[:m]
	crr = list(map(int, input().strip().split()))[:m]
	l1 = []
	l1.append(arr[0])
	for i in range(1, m):
		if arr[i] == l1[-1]:
			l1.append(brr[i])
		else:
			l1.append(arr[i])
		if i == m - 1:
			if l1[-1] == l1[0] or l1[-1] == l1[-2]:
				l1[-1] = arr[i]
			if l1[-1] == l1[0] or l1[-1] == l1[-2]:
				l1[-1] = brr[i]
			if l1[-1] == l1[0] or l1[-1] == l1[-2]:
				l1[-1] = crr[i]
	print(*l1, sep=' ')


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
import sys
letters = ascii_letters[:26]
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	third = list(map(int, input().split()))
	res = [-1] * n
	res[-1] = first[-1]
	if first[0] == first[-1]:
		res[0] = second[0]
	else:
		res[0] = first[0]
	for i in range(1, n - 1):
		if first[i] != res[i - 1] and first[i] != res[i + 1]:
			res[i] = first[i]
		elif second[i] != res[i - 1] and second[i] != res[i + 1]:
			res[i] = second[i]
		else:
			res[i] = third[i]
		last = res[i]
	print(*res)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n,) = gil()
	a = [gil(), gil(), gil()]
	ans = [a[0][0]]
	for i in range(1, n - 1):
		for j in range(3):
			if a[j][i] != ans[-1]:
				ans.append(a[j][i])
				break
	for j in range(3):
		if a[j][-1] != ans[-1] and a[j][-1] != ans[0]:
			ans.append(a[j][-1])
			break
	print(*ans)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		else:
			ans.append(b[i])
	if ans[0] != a[n - 1] and ans[n - 2] != a[n - 1]:
		ans.append(a[n - 1])
	elif ans[0] != b[n - 1] and ans[n - 2] != b[n - 1]:
		ans.append(b[n - 1])
	else:
		ans.append(c[n - 1])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	for m in range(3):
		ans.append([a[0], b[0], c[0]][m])
		for i in range(1, n - 1):
			flag2 = 0
			choices = [a[i], b[i], c[i]]
			for j in range(3):
				flag = 0
				if choices[j] != ans[-1]:
					ans.append(choices[j])
					flag = 1
					break
			if flag == 0:
				flag2 = 1
		if flag2 == 1:
			continue
		choices = [a[-1], b[-1], c[-1]]
		flag3 = 0
		for j in range(3):
			if choices[j] != ans[-1] and choices[j] != ans[0]:
				ans.append(choices[j])
				flag3 = 1
				break
		if flag3 == 0:
			continue
		else:
			print(*ans)
			break


import os
import sys
import io
import functools
import copy
GANS = []

def cmp(x, y):
	if x[1] == y[1]:
		return y[0] - x[0]
	return x[1] - y[1]
t = int(input())
for _ in range(t):
	n = int(input())
	li1 = [int(i) for i in input().split()]
	li2 = [int(i) for i in input().split()]
	li3 = [int(i) for i in input().split()]
	ans = copy.deepcopy(li1)
	for (p, i) in enumerate(ans):
		if i == ans[(p - 1 + n) % n] or i == ans[(p + 1 + n) % n]:
			if li2[p] != ans[(p - 1 + n) % n] and li2[p] != ans[(p + 1 + n) % n]:
				ans[p] = li2[p]
			elif li3[p] != ans[(p - 1 + n) % n] and li3[p] != ans[(p + 1 + n) % n]:
				ans[p] = li3[p]
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	e = [0] * n
	k = 0
	e[0] = a[0]
	for i in range(1, n):
		if a[i] != e[i - 1]:
			e[i] = a[i]
		elif b[i] != e[i - 1]:
			e[i] = b[i]
		else:
			e[i] = c[i]
	if e[0] == e[n - 1]:
		if a[n - 1] != e[0] and a[n - 1] != e[n - 2]:
			e[n - 1] = a[n - 1]
		elif b[n - 1] != e[0] and b[n - 1] != e[n - 2]:
			e[n - 1] = b[n - 1]
		else:
			e[n - 1] = c[n - 1]
	print(*e)


from functools import reduce

def solve(a, b, c):
	ans = [a[0]]
	for i in range(1, len(a) - 1):
		if a[i] == ans[-1]:
			ans.append(b[i])
		else:
			ans.append(a[i])
	exclude = [ans[-1], a[0]]
	if a[-1] not in exclude:
		ans.append(a[-1])
	elif b[-1] not in exclude:
		ans.append(b[-1])
	else:
		ans.append(c[-1])
	return ans
for i in range(int(input())):
	input()
	a = input().split()
	b = input().split()
	c = input().split()
	print(' '.join(solve(a, b, c)))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n):
		(x, y, z) = (a[i], b[i], c[i])
		if p[-1] != x:
			p.append(x)
			continue
		elif p[-1] != y:
			p.append(y)
		elif p[-1] != z:
			p.append(z)
	if p[0] != p[-1]:
		print(*p)
		return
	else:
		(X, Y, Z) = (a[0], b[0], c[0])
		if X != p[1] and X != p[-1]:
			p[0] = X
			print(*p)
			return
		elif Y != p[1] and Y != p[-1]:
			p[0] = Y
			print(*p)
			return
		elif Z != p[1] and Z != p[-1]:
			p[0] = Z
			print(*p)
			return

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


t = int(input())
for m in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	x = len(p)
	while len(p) != n:
		for i in range(x, n):
			if a[i] != p[x - 1]:
				if x != n - 1:
					p.append(a[i])
					x += 1
				elif a[i] != a[0]:
					p.append(a[i])
					x += 1
			else:
				break
		x = len(p)
		if x != n:
			for i in range(x, n):
				if p[x - 1] != b[i]:
					if x != n - 1:
						p.append(b[i])
						x += 1
					elif b[i] != p[0] and p[x - 1] != b[i]:
						p.append(b[i])
						x += 1
				else:
					break
		x = len(p)
		if x != n:
			for i in range(x, n):
				if p[x - 1] != c[i]:
					if x != n - 1:
						p.append(c[i])
						x += 1
					elif c[i] != p[0] and p[x - 1] != c[i]:
						p.append(c[i])
						x += 1
				else:
					break
	for i in p:
		print(i, end=' ')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	n = int(z())
	arr1 = zzz()
	arr2 = zzz()
	arr3 = zzz()
	ans = [arr1[0]]
	for i in range(1, n):
		x1 = arr1[i]
		x2 = arr2[i]
		x3 = arr3[i]
		if i == n - 1:
			if x1 != ans[i - 1] and ans[0] != x1:
				ans.append(x1)
				continue
			if x2 != ans[i - 1] and ans[0] != x2:
				ans.append(x2)
				continue
			if x3 != ans[i - 1] and ans[0] != x3:
				ans.append(x3)
				continue
		if x1 != ans[i - 1]:
			ans.append(x1)
			continue
		if x2 != ans[i - 1]:
			ans.append(x2)
			continue
		if x3 != ans[i - 1]:
			ans.append(x3)
			continue
	print(*ans)


for f in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = a
	for i in range(n):
		if p[i] == p[(i + 1) % n]:
			if p[i] != b[i] and p[(i - 1) % n] != b[i]:
				p[i] = b[i]
			else:
				p[i] = c[i]
	print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [-1 for i in range(n)]
	p[0] = a[0]
	prev = p[0]
	for i in range(1, n):
		if a[i] != prev:
			p[i] = a[i]
		elif b[i] != prev:
			p[i] = b[i]
		else:
			p[i] = c[i]
		prev = p[i]
	if p[0] == p[n - 1]:
		if b[0] != p[1]:
			p[0] = b[0]
		else:
			p[0] = c[0]
	print(*p, sep=' ')


def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		(i, j, k) = (0, 0, 0)
		ans = [a[0]]
		for l in range(1, n - 1):
			if ans[-1] == a[l]:
				ans.append(b[l])
			else:
				ans.append(a[l])
		if ans[0] != a[n - 1] and ans[-1] != a[n - 1]:
			ans.append(a[n - 1])
		elif ans[0] != b[n - 1] and ans[-1] != b[n - 1]:
			ans.append(b[n - 1])
		else:
			ans.append(c[n - 1])
		print(*ans)
main()


import sys
import math
import itertools
import copy
import collections
input = sys.stdin.readline
ttt = int(input())
for tt in range(ttt):
	n = int(input())
	(a, b, c) = ([int(x) for x in input().split()], [int(x) for x in input().split()], [int(x) for x in input().split()])
	p = [-1] * n
	v = a[0]
	prev = None
	for i in range(n):
		if i == 0:
			p[i] = a[0]
			prev = a[0]
		elif i == n - 1:
			if a[i] != v and a[i] != prev:
				p[i] = a[i]
			elif b[i] != v and b[i] != prev:
				p[i] = b[i]
			else:
				p[i] = c[i]
		else:
			if a[i] != prev:
				p[i] = a[i]
			elif b[i] != prev:
				p[i] = b[i]
			else:
				p[i] = c[i]
			prev = p[i]
	print(*p)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	x = 0
	for j in range(1, n):
		x = a[j]
		if j == n - 1:
			if x == p[0] or x == p[j - 1]:
				x = b[j]
			if x == p[0] or x == p[j - 1]:
				x = c[j]
		elif x == p[j - 1]:
			x = b[j]
		p.append(x)
	for a in p:
		print(a, end=' ')
	print('\n')


t = int(input())
s = []
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = [a[0]]
	seq = 1
	j = 1
	while j < n:
		if seq == 1:
			if a[j] != p[j - 1]:
				p.append(a[j])
				j += 1
			else:
				seq = 2
		if seq == 2:
			if b[j] != p[j - 1]:
				p.append(b[j])
				j += 1
			else:
				seq = 3
		if seq == 3:
			if c[j] != p[j - 1]:
				p.append(c[j])
				j += 1
			else:
				seq = 1
	if p[0] == p[n - 1]:
		if a[n - 1] != p[0] and a[n - 1] != p[n - 2]:
			p[n - 1] = a[n - 1]
		elif b[n - 1] != p[0] and b[n - 1] != p[n - 2]:
			p[n - 1] = b[n - 1]
		else:
			p[n - 1] = c[n - 1]
	s.append(' '.join(map(str, p)))
for x in s:
	print(x)


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	out = [a[0]]
	prev = a[0]
	for i in range(1, n - 1):
		vs = set([a[i], b[i], c[i]]) - set([prev])
		prev = vs.pop()
		out.append(prev)
	vs = set([a[-1], b[-1], c[-1]]) - set([prev, out[0]])
	out.append(vs.pop())
	print(*out)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	ans = [arr1[0]]
	for i in range(1, n):
		if i == n - 1:
			if arr1[i] != ans[-1] and arr1[i] != ans[0]:
				ans.append(arr1[i])
				continue
			elif arr2[i] != ans[-1] and arr2[i] != ans[0]:
				ans.append(arr2[i])
			elif arr3[i] != ans[-1] and arr3[i] != ans[0]:
				ans.append(arr3[i])
		elif arr1[i] != ans[-1]:
			ans.append(arr1[i])
			continue
		elif arr2[i] != ans[-1]:
			ans.append(arr2[i])
		elif arr3[i] != ans[-1]:
			ans.append(arr3[i])
	print(*ans)


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

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

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	n = INT()
	arr1 = LIST()
	arr2 = LIST()
	arr3 = LIST()
	ans = [arr1[0]]
	for i in range(1, n - 1):
		if arr1[i] != ans[-1]:
			ans.append(arr1[i])
		elif arr2[i] != ans[-1]:
			ans.append(arr2[i])
		else:
			ans.append(arr3[i])
	if arr1[n - 1] != ans[-1] and arr1[n - 1] != ans[0]:
		ans.append(arr1[n - 1])
	elif arr2[n - 1] != ans[-1] and arr2[n - 1] != ans[0]:
		ans.append(arr2[n - 1])
	else:
		ans.append(arr3[n - 1])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	P = [A[0]]
	for i in range(1, n - 1):
		(a, b, c) = (A[i], B[i], C[i])
		prev = P[-1]
		if prev != a:
			P.append(a)
		elif prev != b:
			P.append(b)
		else:
			P.append(c)
	(a, b, c) = (A[-1], B[-1], C[-1])
	if P[0] != a and P[-1] != a:
		P.append(a)
	elif P[0] != b and P[-1] != b:
		P.append(b)
	else:
		P.append(c)
	print(*P)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	ans = []
	for i in range(n):
		(aa, bb, cc) = (a[i], b[i], c[i])
		if not ans:
			ans += [aa]
		elif i == n - 1:
			if ans[0] != aa and ans[-1] != aa:
				ans += [aa]
			elif ans[0] != bb and ans[-1] != bb:
				ans += [bb]
			else:
				ans += [cc]
		elif ans[-1] != aa:
			ans += [aa]
		elif ans[-1] != bb:
			ans += [bb]
		else:
			ans += [cc]
	print(*ans)


T = int(input())
for t in range(T):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	arr = []
	for i in range(n):
		ar = [a[i], b[i], c[i]]
		ar = list(dict.fromkeys(ar))
		arr.append(ar)
	for i in range(n):
		if i == 0:
			prev = n - 1
		else:
			prev = i - 1
		if i == n - 1:
			nex = 0
		else:
			nex = i + 1
		if len(arr[i]) == 1:
			arr[prev].remove(arr[i][0])
			arr[nex].remove(arr[i][0])
	result = []
	for i in range(n):
		if i == 0:
			prev = n - 1
		else:
			prev = i - 1
		if i == n - 1:
			nex = 0
		else:
			nex = i + 1
		result.append(arr[i][0])
		if arr[i][0] in arr[prev]:
			arr[prev].remove(arr[i][0])
		if arr[i][0] in arr[nex]:
			arr[nex].remove(arr[i][0])
	for i in range(n):
		print(result[i], end=' ')
	print()


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	new = [a[0]]
	for i in range(1, n - 1):
		if a[i] != new[i - 1]:
			new.append(a[i])
		else:
			new.append(b[i])
	if a[n - 1] == new[0] or a[n - 1] == new[-1]:
		if b[n - 1] == new[0] or b[n - 1] == new[-1]:
			new.append(c[-1])
		else:
			new.append(b[-1])
	else:
		new.append(a[-1])
	for i in new:
		print(i, end=' ')
	print()
t = int(input())
for i in range(t):
	main()


def solve(n, a, b, c):
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] != ans[-1]:
			ans.append(a[i])
		elif b[i] != ans[-1]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	if a[-1] != ans[-1] and a[-1] != ans[0]:
		ans.append(a[-1])
	elif b[-1] != ans[-1] and b[-1] != ans[0]:
		ans.append(b[-1])
	else:
		ans.append(c[-1])
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(*solve(n, a, b, c))


testcases = int(input())
for testcase in range(testcases):
	n = int(input())
	arra = []
	arrb = []
	arrc = []
	temparr = input()
	temparr = temparr.split()
	for i in temparr:
		arra.append(int(i))
	temparr = input()
	temparr = temparr.split()
	for i in temparr:
		arrb.append(int(i))
	temparr = input()
	temparr = temparr.split()
	for i in temparr:
		arrc.append(int(i))
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(arra[i])
			continue
		elif i != n - 1:
			if arra[i] != ans[-1]:
				ans.append(arra[i])
				continue
			elif arrb[i] != ans[-1]:
				ans.append(arrb[i])
				continue
			else:
				ans.append(arrc[i])
		elif arra[i] != ans[-1] and arra[i] != ans[0]:
			ans.append(arra[i])
		elif arrb[i] != ans[-1] and arrb[i] != ans[0]:
			ans.append(arrb[i])
		else:
			ans.append(arrc[i])
	sans = []
	for i in ans:
		sans.append(str(i))
	print(' '.join(sans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	temp = a[0]
	print(temp, end=' ')
	for (i, j, k) in zip(a[1:-1], b[1:-1], c[1:-1]):
		if i != temp:
			print(i, end=' ')
			temp = i
		elif j != temp:
			print(j, end=' ')
			temp = j
		else:
			print(k, end=' ')
			temp = k
	if a[-1] != a[0] and a[-1] != temp:
		print(a[-1])
	elif b[-1] != a[0] and b[-1] != temp:
		print(b[-1])
	else:
		print(c[-1])


T = int(input())
for t in range(T):
	n = int(input())
	arr1 = [int(s) for s in input().split()]
	arr2 = [int(s) for s in input().split()]
	arr3 = [int(s) for s in input().split()]
	p = list()
	prev = -1
	for (a, b, c) in zip(arr1[0:-1], arr2, arr3):
		for new_p in [a, b, c]:
			if new_p != prev:
				p.append(new_p)
				prev = new_p
				break
	for new_p in [arr1[-1], arr2[-1], arr3[-1]]:
		if new_p != p[-1] and new_p != p[0]:
			p.append(new_p)
			break
	for i in p:
		print(i, end=' ')
	print()


def parser():
	while 1:
		data = list(input().split(' '))
		for number in data:
			if len(number) > 0:
				yield number
input_parser = parser()

def get_word():
	global input_parser
	return next(input_parser)

def get_number():
	data = get_word()
	try:
		return int(data)
	except ValueError:
		return float(data)

def generate_word(n, long_word):
	target = ''
	counter = 0
	while n != 0:
		target = target + long_word[counter]
		long_word = long_word[1:]
		n = n - 1
		counter = counter + 1
	print(target)
test_cases = get_number()
for i in range(0, test_cases):
	n = get_number()
	a = []
	b = []
	c = []
	final = []
	for i in range(n):
		a.append(get_number())
	for i in range(n):
		b.append(get_number())
	for i in range(n):
		c.append(get_number())
	final.append(a[0])
	for i in range(0, n - 1):
		my_next = i + 1
		if my_next == n - 1:
			if final[i] != a[my_next] and a[my_next] != final[0]:
				final.append(a[my_next])
				continue
			if final[i] != b[my_next] and b[my_next] != final[0]:
				final.append(b[my_next])
				continue
			if final[i] != c[my_next] and c[my_next] != final[0]:
				final.append(c[my_next])
				continue
		else:
			if final[i] != a[my_next]:
				final.append(a[my_next])
				continue
			if final[i] != b[my_next]:
				final.append(b[my_next])
				continue
			if final[i] != c[my_next]:
				final.append(c[my_next])
				continue
	print(' '.join((str(i) for i in final)))


def solve():
	N = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	P = [A[0]]
	for i in range(1, N - 1):
		for x in [A[i], B[i], C[i]]:
			if x != P[-1]:
				P.append(x)
				break
	for x in [A[-1], B[-1], C[-1]]:
		if x != P[0] and x != P[-1]:
			P.append(x)
			break
	return ' '.join(map(str, P))
TC = int(input())
for _ in range(TC):
	print(solve())


import math
t = int(input())
for test in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = [A[0]]
	for i in range(1, n - 1):
		if A[i] != ans[-1]:
			ans.append(A[i])
		elif B[i] != ans[-1]:
			ans.append(B[i])
		elif C[i] != ans[-1]:
			ans.append(C[i])
	if A[n - 1] != ans[-1] and A[n - 1] != ans[0]:
		ans.append(A[n - 1])
	elif B[n - 1] != ans[-1] and B[n - 1] != ans[0]:
		ans.append(B[n - 1])
	elif C[n - 1] != ans[-1] and C[n - 1] != ans[0]:
		ans.append(C[n - 1])
	print(*ans)


import collections
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	i = 0
	ans = []
	while len(ans) < n:
		if len(ans) == 0:
			ans.append(a[i])
		elif len(ans) < n - 1:
			if a[i] != ans[-1]:
				ans.append(a[i])
			elif b[i] != ans[-1]:
				ans.append(b[i])
			else:
				ans.append(c[i])
		elif a[i] != ans[-1] and a[i] != ans[0]:
			ans.append(a[i])
		elif b[i] != ans[-1] and b[i] != ans[0]:
			ans.append(b[i])
		else:
			ans.append(c[i])
		i += 1
	print(*ans)


from sys import stdin
input = stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = [0] * n
	res[0] = a[0]
	for i in range(1, n):
		if a[i] != res[i - 1]:
			res[i] = a[i]
		else:
			res[i] = b[i]
	prev = res[n - 2]
	nxt = res[0]
	if a[n - 1] != prev and a[n - 1] != nxt:
		res[n - 1] = a[n - 1]
	elif b[n - 1] != prev and b[n - 1] != nxt:
		res[n - 1] = b[n - 1]
	else:
		res[n - 1] = c[n - 1]
	print(' '.join(map(str, res)))
t = int(input())
for _ in range(t):
	solve()


import sys

def main():
	T = int(input())
	for ti in range(T):
		n = int(input())
		A = [int(v) for v in input().split()]
		B = [int(v) for v in input().split()]
		C = [int(v) for v in input().split()]
		ans = [A[0]]
		for i in range(1, len(A) - 1):
			if A[i] != ans[i - 1]:
				ans.append(A[i])
			else:
				ans.append(B[i])
		if A[-1] != ans[-1] and A[-1] != ans[0]:
			ans.append(A[-1])
		elif B[-1] != ans[-1] and B[-1] != ans[0]:
			ans.append(B[-1])
		else:
			ans.append(C[-1])
		print(' '.join(map(str, ans)))
main()


def solve(a, b, c):
	p = [a[0]]
	for i in range(1, len(a) - 1):
		if a[i] != p[i - 1]:
			p.append(a[i])
		elif b[i] != p[i - 1]:
			p.append(b[i])
		elif c[i] != p[i - 1]:
			p.append(c[i])
	if a[-1] != p[0] and a[-1] != p[-1]:
		p.append(a[-1])
	elif b[-1] != p[0] and b[-1] != p[-1]:
		p.append(b[-1])
	elif c[-1] != p[0] and c[-1] != p[-1]:
		p.append(c[-1])
	return p

def main():
	t = int(input())
	for _ in range(t):
		_ = int(input())
		a = [int(val) for val in input().split()]
		b = [int(val) for val in input().split()]
		c = [int(val) for val in input().split()]
		result = solve(a, b, c)
		print(*result, sep=' ')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	for i in range(3):
		l.append([int(i) for i in input().split()])
	k = [l[0][0]]
	for i in range(1, n):
		if l[0][i] != k[-1] and i != n - 1:
			k.append(l[0][i])
		elif i == n - 1 and l[0][i] != k[0] and (l[0][i] != k[-1]):
			k.append(l[0][i])
		else:
			p = 1
			while p < 3:
				if i == n - 1 and (l[p][i] == k[0] or l[p][i] == k[-1]):
					p += 1
				elif i != n - 1 and l[p][i] == k[-1]:
					p += 1
				else:
					break
			k.append(l[p][i])
	print(' '.join(map(str, k)))


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = a[0]
	for i in range(1, n):
		poss_val = [a[i], b[i], c[i]]
		for j in range(0, 3):
			if ans[i - 1] != poss_val[j] and (i == n - 1 and poss_val[j] == ans[0]) == False:
				ans[i] = poss_val[j]
	print(' '.join(map(str, ans)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	step = []
	ans.append(a[0])
	f = False
	d = False
	for j in range(1, n):
		step.append(a[j])
		step.append(b[j])
		step.append(c[j])
		for l in range(len(step)):
			if d:
				continue
			if ans[-1] == step[l]:
				continue
			if j == n - 1:
				if step[l] == ans[0]:
					continue
				ans.append(step[l])
				f = True
				break
			else:
				ans.append(step[l])
				d = True
		if f:
			break
		step.clear()
		d = False
	print(*ans)


t = int(input())
for t in range(t):
	t1 = int(input())
	lst = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	q = []
	q.append(lst[0])
	for i in range(1, len(lst) - 1):
		if q[i - 1] == lst[i]:
			q.append(lst1[i])
		else:
			q.append(lst[i])
	if q[-1] != lst[-1] and q[0] != lst[-1]:
		q.append(lst[-1])
	elif q[-1] != lst1[-1] and q[0] != lst1[-1]:
		q.append(lst1[-1])
	else:
		q.append(lst2[-1])
	print(*q)


try:
	from collections import defaultdict
	t = int(input())
	while t != 0:
		n = int(input())
		A = list(map(int, input().split()))
		B = list(map(int, input().split()))
		C = list(map(int, input().split()))
		temp = defaultdict(list)
		for i in range(n):
			temp[i].append(A[i])
			temp[i].append(B[i])
			temp[i].append(C[i])
		result = [0] * n
		for i in range(n - 1):
			if len(temp[i + 1]) == 1:
				p = temp[i + 1]
				j = 0
				q = temp[i]
				while j != len(temp[i]):
					if q[j] != p[0]:
						if i != 0 and q[j] != result[i - 1]:
							result[i] = q[j]
							break
						elif i == 0:
							result[i] = q[j]
							break
					j += 1
			else:
				q = temp[i]
				j = 0
				while j != len(q):
					if i == 0:
						result[i] = q[j]
						break
					elif q[j] != result[i - 1]:
						result[i] = q[j]
						break
					j += 1
		for i in temp[n - 1]:
			if i != result[n - 2] and i != result[0]:
				result[n - 1] = i
				break
		print(*result)
except EOFError:
	print(' ')


import sys
import math
mod = 998244353
dynamic_factorial = False

def main(test_case=False):
	n = int(input()) if test_case else 1
	for _ in range(n):
		test()
		print()

def fast_pow(a: int, b: int):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def c2(n):
	return n * (n - 1) // 2

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

def bits(n: int):
	return list(bin(n)).count('1')

def flush():
	sys.stdout.flush()

def parr(arr):
	print(*arr, sep=' ')

def gcd(a, b):
	while b:
		if b % a == 0:
			break
		tmp = a
		a = b % a
		b = tmp
	return a

def ext_gcd(a: int, b: int):
	if b == 0:
		return [a, [1, 0]]
	res = ext_gcd(b, a % b)
	g = res[0]
	if g != 1:
		return False
	x1 = res[1][0]
	y1 = res[1][1]
	x = y1
	y = x1 - y1 * (a // b)
	return [g, [x, y]]

def get_set(a):
	res = {}
	for x in a:
		if x in res:
			res[x] += 1
		else:
			res[x] = 1
	return res
fact = {0: 1}

def factorial(n):
	if dynamic_factorial:
		if n not in fact:
			fact[n] = factorial(n - 1) * n
		return fact[n]
	else:
		res = 1
		while n > 0:
			res = res * n % mod
			n -= 1
		return res

def sum_of(a):
	res = 0
	for x in a:
		res = (res + x) % mod
	return res

def prod_of(a):
	res = 1
	for x in a:
		res = res * x % mod
	return res

def test():
	n = get()[0]
	(a, b, c) = (get(), get(), get())
	ans = [a[0]]
	i = 1
	while i < n - 1:
		if ans[i - 1] == a[i]:
			ans.append(b[i])
		else:
			ans.append(a[i])
		i += 1
	ans.append(0)
	if a[i] != ans[i - 1] and a[i] != ans[0]:
		ans[i] = a[i]
	elif b[i] != ans[i - 1] and b[i] != ans[0]:
		ans[i] = b[i]
	elif c[i] != ans[i - 1] and c[i] != ans[0]:
		ans[i] = c[i]
	parr(ans)
main(test_case=True)


t = int(input())
for _ in range(t):
	count = 0
	n = int(input())
	l = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l.append(a)
	l.append(b)
	l.append(c)
	m = [0]
	m[count] = l[0][0]
	for j in range(1, n):
		for i in range(3):
			if m[count] != l[i][j]:
				m.append(l[i][j])
				count += 1
				break
		if count == n - 2:
			break
	for k in range(3):
		if m[0] != l[k][-1] and m[-1] != l[k][-1]:
			m.append(l[k][-1])
			break
	for y in m:
		print(y, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	prev = -1
	res = []
	for i in range(0, n - 1):
		if l1[i] != l1[(i + 1) % n] and prev != l1[i]:
			res.append(l1[i])
		elif l1[i] != l2[(i + 1) % n] and prev != l1[i]:
			res.append(l1[i])
		elif l1[i] != l3[(i + 1) % n] and prev != l1[i]:
			res.append(l1[i])
		elif l2[i] != l1[(i + 1) % n] and prev != l2[i]:
			res.append(l2[i])
		elif l2[i] != l2[(i + 1) % n] and prev != l2[i]:
			res.append(l2[i])
		elif l2[i] != l3[(i + 1) % n] and prev != l2[i]:
			res.append(l2[i])
		elif l3[i] != l1[(i + 1) % n] and prev != l3[i]:
			res.append(l3[i])
		elif l3[i] != l2[(i + 1) % n] and prev != l3[i]:
			res.append(l3[i])
		elif l3[i] != l3[(i + 1) % n] and prev != l3[i]:
			res.append(l3[i])
		prev = res[-1]
	if l1[n - 1] != prev and l1[n - 1] != res[0]:
		res.append(l1[n - 1])
	elif l2[n - 1] != prev and l2[n - 1] != res[0]:
		res.append(l2[n - 1])
	elif l3[n - 1] != prev and l3[n - 1] != res[0]:
		res.append(l3[n - 1])
	for i in res:
		print(i, end=' ')
	print()


t = int(input())
for r in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	w = [a[0]]
	x = 0
	y = 0
	for i in range(1, n - 1):
		if b[i] != w[i - 1]:
			w.append(b[i])
		elif c[i] != w[i - 1]:
			w.append(c[i])
		else:
			w.append(a[i])
	if a[-1] != w[0] and a[-1] != w[-1]:
		w.append(a[-1])
	elif b[-1] != w[0] and b[-1] != w[-1]:
		w.append(b[-1])
	else:
		w.append(c[-1])
	for i in w:
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	a = []
	b = []
	c = []
	for i in range(3):
		if i == 0:
			line = list(map(int, input().split()))
			a = line
		elif i == 1:
			line = list(map(int, input().split()))
			b = line
		elif i == 2:
			line = list(map(int, input().split()))
			c = line
	answer = [0 for _ in range(n)]
	for i in range(n):
		geta = a[i]
		getb = b[i]
		getc = c[i]
		if i == 0:
			answer[i] = geta
		elif i == n - 1:
			if geta != answer[0] and geta != answer[i - 1]:
				answer[i] = geta
			elif getb != answer[0] and getb != answer[i - 1]:
				answer[i] = getb
			else:
				answer[i] = getc
		elif geta != answer[i - 1]:
			answer[i] = geta
		elif getb != answer[i - 1]:
			answer[i] = getb
		else:
			answer[i] = getc
	getanswer = ''
	for i in answer:
		getanswer += str(i)
		getanswer += ' '
	print(getanswer)


import sys
import os
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')
mod = 10 ** 9 + 7

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

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, a, b, c):
	ans = []
	prev = -1
	for i in range(n):
		if i != n - 1:
			if prev == -1 or a[i] != prev:
				ans.append(a[i])
				prev = a[i]
			elif prev == -1 or b[i] != prev:
				ans.append(b[i])
				prev = b[i]
			elif prev == -1 or c[i] != prev:
				ans.append(c[i])
				prev = c[i]
		elif a[i] != ans[i - 1] and a[i] != ans[0]:
			ans.append(a[i])
			prev = a[i]
		elif b[i] != ans[i - 1] and b[i] != ans[0]:
			ans.append(b[i])
			prev = b[i]
		elif c[i] != ans[i - 1] and c[i] != ans[0]:
			ans.append(c[i])
			prev = c[i]
	return ' '.join(list(map(str, ans)))
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(solve(n, a, b, c))


def chk(l):
	if l[-1] == l[0]:
		return False
	for i in range(1, len(l)):
		if l[i - 1] == l[i]:
			return False
	return True
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for k in range(3):
		p = [0] * n
		if k == 0:
			p[0] = a[0]
		elif k == 1:
			p[0] = b[0]
		else:
			p[0] = c[0]
		for i in range(1, n):
			if p[i - 1] != a[i]:
				p[i] = a[i]
			elif p[i - 1] != b[i]:
				p[i] = b[i]
			else:
				p[i] = c[i]
		if chk(p):
			print(*p)
			break


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(a[i])
		elif i == n - 1:
			lis = [a[i], b[i], c[i]]
			for j in range(3):
				if lis[j] != ans[0] and lis[j] != ans[-1]:
					ans.append(lis[j])
					break
		elif ans[-1] == a[i]:
			ans.append(b[i])
		else:
			ans.append(a[i])
	print(' '.join((str(x) for x in ans)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	s = [a, b, c]
	l = None
	curr = 0
	for i in range(n - 1):
		if s[curr][i] == l:
			curr = (curr + 1) % 3
		print(s[curr][i], end=' ')
		l = s[curr][i]
	if l != a[-1] and a[-1] != a[0]:
		print(a[-1])
	elif l != b[-1] and b[-1] != a[0]:
		print(b[-1])
	else:
		print(c[-1])


t = int(input())
for i in range(t):
	n = int(input())
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	cc = list(map(int, input().split()))
	xx = []
	for i in range(n):
		if i == 0:
			xx.append(aa[0])
		elif i == n - 1:
			if aa[i] != xx[i - 1] and aa[i] != xx[0]:
				xx.append(aa[i])
			elif bb[i] != xx[i - 1] and bb[i] != xx[0]:
				xx.append(bb[i])
			else:
				xx.append(cc[i])
		elif xx[i - 1] == aa[i]:
			if xx[i - 1] == bb[i]:
				xx.append(cc[i])
			else:
				xx.append(bb[i])
		else:
			xx.append(aa[i])
	print(*xx)


t = int(input())
for t in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	p = []
	for i in range(n):
		if i == 0:
			if l1[i] != l1[i + 1]:
				p.append(l1[i])
			elif l2[i] != l2[i + 1]:
				p.append(l2[i])
			else:
				p.append(l3[i])
		elif i != n - 1:
			if l1[i] != p[i - 1]:
				p.append(l1[i])
			elif l2[i] != p[i - 1]:
				p.append(l2[i])
			else:
				p.append(l3[i])
		elif l1[i] != p[0] and l1[i] != p[i - 1]:
			p.append(l1[i])
		elif l2[i] != p[0] and l2[i] != p[i - 1]:
			p.append(l2[i])
		elif l3[i] != p[0] and l3[i] != p[i - 1]:
			p.append(l3[i])
		else:
			x = l1[0]
			y = l2[0]
			z = l3[0]
			if x != l1[1] and x != l1[n - 1]:
				p[0] = x
				p.append(l1[n - 1])
			elif y != l2[1] and x != l2[n - 1]:
				p[0] = y
				p.append(l2[n - 1])
			else:
				p[0] = z
				p.append(l3[n - 1])
	print(*p)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	n = inp()
	dt = {0: [], 1: [], 2: []}
	dt[0] = ip()
	dt[1] = ip()
	dt[2] = ip()
	for k in range(3):
		ans = [-1] * n
		ans[0] = dt[k][0]
		for i in range(1, n):
			for j in range(3):
				if dt[j][i] != ans[i - 1]:
					if i == n - 1:
						if dt[j][i] != ans[0]:
							ans[i] = dt[j][i]
							break
					else:
						ans[i] = dt[j][i]
						break
		if -1 not in ans:
			break
	print(*ans)


T = int(input())
for z in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	out = list()
	for i in range(n):
		if i == 0:
			out.append(a[0])
		elif i != n - 1:
			if out[i - 1] != a[i]:
				out.append(a[i])
			else:
				out.append(b[i])
		elif out[i - 1] != a[i] and out[0] != a[i]:
			out.append(a[i])
		elif out[i - 1] != b[i] and out[0] != b[i]:
			out.append(b[i])
		else:
			out.append(c[i])
	for i in range(n):
		print(out[i], end=' ')
	print('')


test = int(input())
for i in range(test):
	n = int(input())
	l1 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	lst = []
	for k in range(n):
		if k == 0:
			lst.append(l1[k])
		elif k == n - 1:
			if lst[k - 1] != l1[k] and lst[0] != l1[k]:
				lst.append(l1[k])
			elif lst[k - 1] != l2[k] and lst[0] != l2[k]:
				lst.append(l2[k])
			else:
				lst.append(l3[k])
		elif lst[k - 1] != l1[k]:
			lst.append(l1[k])
		elif lst[k - 1] != l2[k]:
			lst.append(l2[k])
		else:
			lst.append(l3[k])
	for t in lst:
		print(t, end=' ')
	print()


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		p = [0] * n
		p[0] = a[0]
		for i in range(1, n - 1):
			if a[i] != p[i - 1]:
				p[i] = a[i]
			else:
				p[i] = b[i]
		if a[n - 1] != p[0] and a[n - 1] != p[n - 2]:
			p[n - 1] = a[n - 1]
		elif b[n - 1] != p[0] and b[n - 1] != p[n - 2]:
			p[n - 1] = b[n - 1]
		else:
			p[n - 1] = c[n - 1]
		print(*p)

def B():
	t = int(input())
	for _ in range(t):
		__ = 0

def C():
	t = int(input())
	for _ in range(t):
		__ = 0

def D():
	t = int(input())
	for _ in range(t):
		__ = 0

def E():
	t = int(input())
	for _ in range(t):
		__ = 0

def F():
	t = int(input())
	for _ in range(t):
		__ = 0
A()


import os
import sys
from io import BytesIO, IOBase

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [0] * n
	p[-1] = a[-1]
	for i in reversed(range(n - 1)):
		if a[i] != p[i + 1]:
			p[i] = a[i]
		elif b[i] != p[i + 1]:
			p[i] = b[i]
		else:
			p[i] = c[i]
	if p[n - 1] == p[0]:
		if a[n - 1] != p[0] and p[n - 2] != a[n - 1]:
			p[n - 1] = a[n - 1]
		elif b[n - 1] != p[0] and p[n - 2] != b[n - 1]:
			p[n - 1] = b[n - 1]
		else:
			p[n - 1] = c[n - 1]
	print(*p)

def main():
	testcases = 1
	testcases = int(input())
	for _ in range(testcases):
		solution()
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 math
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = a[0]
	for i in range(1, n):
		x = a[i]
		y = b[i]
		z = c[i]
		if x != ans[i - 1]:
			ans[i] = x
		elif y != ans[i - 1]:
			ans[i] = y
		else:
			ans[i] = z
	if ans[0] == ans[n - 1]:
		x = a[n - 1]
		y = b[n - 1]
		z = c[n - 1]
		if x != a[0] and x != ans[n - 2]:
			ans[n - 1] = x
		elif y != a[0] and y != ans[n - 2]:
			ans[n - 1] = y
		if z != a[0] and z != ans[n - 2]:
			ans[n - 1] = z
	print(' '.join((str(a) for a in ans)))


for _ in range(int(input())):
	n = int(input())
	a = []
	for j in range(3):
		a.append(list(map(int, input().split())))
	i = 1
	flag = True
	ans = [a[0][0]]
	cnt = 1
	while flag:
		if len(ans) == n - 1:
			if ans[-1] != a[0][i] and ans[0] != a[0][i]:
				ans.append(a[0][i])
			elif ans[-1] != a[1][i] and ans[0] != a[1][i]:
				ans.append(a[1][i])
			elif ans[-1] != a[2][i] and ans[0] != a[2][i]:
				ans.append(a[2][i])
		elif ans[-1] != a[0][i]:
			ans.append(a[0][i])
		elif ans[-1] != a[1][i]:
			ans.append(a[1][i])
		elif ans[-1] != a[2][i]:
			ans.append(a[2][i])
		if len(ans) == n:
			flag = False
		i += 1
	print(*ans)


t = int(input())
for nbt in range(t):
	n = [int(i) for i in input().split()][0]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	r = [None] * n
	for i in range(0, n, 2):
		r[i] = a[i]
	if r[0] == r[-1]:
		r[-1] = b[-1]
	for i in range(1, n, 2):
		for z in (a, b, c):
			if r[i - 1] != z[i] and r[(i + 1) % n] != z[i]:
				r[i] = z[i]
	print(*r)


TC = int(input())
A = []
B = []
C = []
R = []

def find(i):
	if i == N:
		if R[-1] != R[0]:
			return True
		else:
			return False
	if R[i - 1] != A[i]:
		R[i] = A[i]
		if find(i + 1):
			return True
	if R[i - 1] != B[i]:
		R[i] = B[i]
		if find(i + 1):
			return True
	if R[i - 1] != C[i]:
		R[i] = C[i]
		if find(i + 1):
			return True
	return False
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	R = [-1] * N
	R[0] = A[0]
	if find(1):
		for r in R:
			print(r, end=' ')
		print()
		continue
	R[0] = B[0]
	if find(1):
		for r in R:
			print(r, end=' ')
		print()
		continue
	R[0] = B[0]
	if find(1):
		for r in R:
			print(r, end=' ')
		print()
		continue


import sys
import math
t = int(input().strip())
for a0 in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	l2 = [int(i) for i in input().split()]
	l3 = [int(i) for i in input().split()]
	m = []
	m.append(l1[0])
	for i in range(1, n - 1):
		if l1[i] != m[i - 1]:
			m.append(l1[i])
		elif l2[i] != m[i - 1]:
			m.append(l2[i])
		else:
			m.append(l3[i])
	a = [l1[n - 1], l2[n - 1], l3[n - 1]]
	for i in a:
		if i != m[n - 2] and i != m[0]:
			m.append(i)
			break
	s = ''
	for i in range(n):
		s += str(m[i]) + ' '
	print(s)


t = int(input())
h = 1
while h <= t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	f = 0
	for i in range(0, n):
		if i == 0:
			print(a[i], end=' ')
			f = a[i]
		elif i == n - 1:
			if b[i] != f and b[i] != a[0]:
				print(b[i], end=' ')
			elif c[i] != f and c[i] != a[0]:
				print(c[i], end=' ')
			else:
				print(a[i], end=' ')
		elif a[i] != f:
			print(a[i], end=' ')
			f = a[i]
		elif b[i] != f:
			print(b[i], end=' ')
			f = b[i]
		else:
			print(c[i], end=' ')
			f = c[i]
	h += 1
	print()


t = int(input())
while t:
	n = int(input())
	a = list(input().split(' '))
	b = list(input().split(' '))
	c = list(input().split(' '))
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] != ans[-1]:
			ans.append(a[i])
		elif b[i] != ans[-1]:
			ans.append(b[i])
		elif c[i] != ans[-1]:
			ans.append(c[i])
	if a[-1] != ans[-1] and a[-1] != ans[0]:
		ans.append(a[-1])
	elif b[-1] != ans[-1] and b[-1] != ans[0]:
		ans.append(b[-1])
	elif c[-1] != ans[-1] and c[-1] != ans[0]:
		ans.append(c[-1])
	print(' '.join(ans))
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	print(a[0], end=' ')
	res = a[0]
	for i in range(1, n - 1):
		if a[i] == res:
			res = b[i]
		else:
			res = a[i]
		print(res, end=' ')
	if a[-1] == res or a[-1] == a[0]:
		if b[-1] == res or b[-1] == a[0]:
			print(c[-1], end=' ')
		else:
			print(b[-1], end=' ')
	else:
		print(a[-1], end=' ')
	print(end='\n')


t = int(input())
for u in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = [a[0]]
	for i in range(1, n - 1):
		if a[i] != d[i - 1]:
			d.append(a[i])
		else:
			d.append(b[i])
	if a[n - 1] != d[0] and a[n - 1] != d[n - 2]:
		d.append(a[n - 1])
	elif b[n - 1] != d[0] and b[n - 1] != d[n - 2]:
		d.append(b[n - 1])
	else:
		d.append(c[n - 1])
	print(*d)


def func(n, a, b, c):
	arr = [a[0]]
	for i in range(1, n):
		if a[i] == arr[-1]:
			arr.append(b[i])
		else:
			arr.append(a[i])
	if arr[-1] == arr[0]:
		temp = arr.pop()
		if a[-1] != temp and a[-1] != arr[-1]:
			arr.append(a[-1])
		elif b[-1] != temp and b[-1] != arr[-1]:
			arr.append(b[-1])
		elif c[-1] != temp and c[-1] != arr[-1]:
			arr.append(c[-1])
	print(*arr)
	return
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	func(n, a, b, c)


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import sys
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n - 1):
		if ans[-1] != a[i]:
			tmp = a[i]
		else:
			tmp = b[i]
		ans.append(tmp)
	if a[-1] != ans[0] and a[-1] != ans[-1]:
		ans.append(a[-1])
	elif b[-1] != ans[0] and b[-1] != ans[-1]:
		ans.append(b[-1])
	else:
		ans.append(c[-1])
	print(*ans)


def solve(n, arr, brr, crr):
	prev = 0
	for i in range(n):
		if i == n - 1:
			myset = {arr[0], prev}
			if arr[i] not in myset:
				print(arr[i])
			elif brr[i] not in myset:
				print(brr[i])
			else:
				print(crr[i])
			break
		if arr[i] != prev:
			print(arr[i], end=' ')
			prev = arr[i]
		elif brr[i] != prev:
			print(brr[i], end=' ')
			prev = brr[i]
		else:
			print(crr[i], end=' ')
			prev = crr[i]
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(map(int, input().split()))
	solve(n, arr, brr, crr)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	c = list(map(int, input().strip().split(' ')))
	p = [a[0]]
	for j in range(1, n - 1):
		if p[-1] != a[j]:
			p.append(a[j])
		elif p[-1] != b[j]:
			p.append(b[j])
		else:
			p.append(c[j])
	if p[0] != a[n - 1] and p[-1] != a[n - 1]:
		p.append(a[n - 1])
	elif p[0] != b[n - 1] and p[-1] != b[n - 1]:
		p.append(b[n - 1])
	else:
		p.append(c[n - 1])
	for j in range(n):
		print(p[j], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = []
	for i in range(3):
		x = input().strip(' ').split(' ')
		arr.append(x)
	i = 1
	ans = [arr[0][0]]
	while i < n - 1:
		if ans[-1] != arr[0][i]:
			ans.append(arr[0][i])
			i += 1
			continue
		if ans[-1] != arr[1][i]:
			ans.append(arr[1][i])
			i += 1
			continue
		if ans[-1] != arr[1][i]:
			ans.append(arr[2][i])
			i += 1
			continue
	if ans[-1] != arr[0][i] and ans[0] != arr[0][i]:
		ans.append(arr[0][i])
		print(' '.join(ans))
		continue
	if ans[-1] != arr[1][i] and ans[0] != arr[1][i]:
		ans.append(arr[1][i])
		print(' '.join(ans))
		continue
	if ans[-1] != arr[2][i] and ans[0] != arr[2][i]:
		ans.append(arr[2][i])
		print(' '.join(ans))
		continue


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	l = [a[0]]
	i = 1
	while i < n:
		while i < n and l[i - 1] != a[i]:
			l.append(a[i])
			i += 1
		while i < n and l[i - 1] != b[i]:
			l.append(b[i])
			i += 1
		while i < n and l[i - 1] != c[i]:
			l.append(c[i])
			i += 1
	if l[0] == l[n - 1]:
		if a[n - 1] != l[n - 2] and a[n - 1] != l[0]:
			l[n - 1] = a[n - 1]
		elif b[n - 1] != l[n - 2] and b[n - 1] != l[0]:
			l[n - 1] = b[n - 1]
		else:
			l[n - 1] = c[n - 1]
	for i in l:
		print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(1, n):
		if a[i] == a[i - 1]:
			a[i] = b[i]
			if a[i] == a[i - 1]:
				a[i] = b[i]
			if a[i] == a[i - 1]:
				a[i] = c[i]
	if a[0] == a[-1]:
		a[-1] = c[-1]
	if a[-1] == a[-2]:
		a[-1] = b[-1]
	print(*a)


PI = 3.141592653589793
INF = 999999999
MOD = 1000000007

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

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

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	n = ii()
	a = li()
	b = li()
	c = li()
	p = [0 for i in range(n)]
	p[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p[i] = a[i]
		elif b[i] != p[i - 1]:
			p[i] = b[i]
		elif c[i] != p[i - 1]:
			p[i] = c[i]
	if a[n - 1] != p[0] and a[n - 1] != p[n - 2]:
		p[n - 1] = a[n - 1]
	elif b[n - 1] != p[0] and b[n - 1] != p[n - 2]:
		p[n - 1] = b[n - 1]
	elif c[n - 1] != p[0] and c[n - 1] != p[n - 2]:
		p[n - 1] = c[n - 1]
	print(*p)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for j in range(1, n):
		if a[j] == a[j - 1]:
			a[j] = b[j]
			if a[j] == a[j - 1]:
				a[j] = c[j]
	if a[-1] == a[-2] or a[-1] == a[0]:
		if b[-1] != a[-2] and b[-1] != a[0]:
			a[-1] = b[-1]
		else:
			a[-1] = c[-1]
	print(*a)


def proA(n, arr, arr2, arr3):
	temp = []
	for i in range(n):
		for j in [arr, arr2, arr3]:
			if len(temp) == n - 1 and temp[0] == j[i]:
				continue
			if temp != []:
				if temp[-1] == j[i]:
					continue
			temp.append(j[i])
			break
	printA(temp)

def printA(arr):
	for i in arr:
		print(i, end=' ')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	proA(n, arr, arr2, arr3)


import math
for z in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	p = [a[0]]
	for i in range(1, n - 1):
		if p[i - 1] != a[i]:
			p.append(a[i])
		elif p[i - 1] != b[i]:
			p.append(b[i])
		else:
			p.append(c[i])
	i = n - 1
	if n > 1:
		if p[i - 1] != a[i] and a[i] != p[0]:
			p.append(a[i])
		elif p[i - 1] != b[i] and b[i] != p[0]:
			p.append(b[i])
		else:
			p.append(c[i])
	print(*p)


import sys
for test in range(int(input())):
	n = int(input())
	a = [int(x) for x in sys.stdin.readline().split()]
	b = [int(x) for x in sys.stdin.readline().split()]
	c = [int(x) for x in sys.stdin.readline().split()]
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] == ans[i - 1]:
			ans.append(b[i])
		else:
			ans.append(a[i])
	final = [ans[0], ans[-1]]
	if a[-1] in final:
		if b[-1] in final:
			ans.append(c[-1])
		else:
			ans.append(b[-1])
	else:
		ans.append(a[-1])
	print(*ans)


def solve():
	case = int(input())
	for _case in range(case):
		n = int(input())
		li = [[], [], []]
		for i in range(3):
			li[i] = list(map(int, input().split()))
		line = 0
		ans = []
		ans.append(li[line][0])
		for i in range(1, n):
			if i == n - 1:
				while ans[0] == li[line][i] or ans[i - 1] == li[line][i]:
					line = (line + 1) % 3
				ans.append(li[line][i])
				break
			if ans[i - 1] == li[line][i]:
				line = (line + 1) % 3
			ans.append(li[line][i])
		print(' '.join((str(i) for i in ans)))
solve()


import math
import os
import random
import re
import sys

def fu(n, a, b, c):
	mewl = []
	for i in range(0, n):
		mewl.append([a[i], b[i], c[i]])
	p = [mewl[0][0]]
	for i in range(1, n):
		for j in range(3):
			if i == n - 1:
				if mewl[n - 1][j] != p[n - 2] and mewl[n - 1][j] != p[0]:
					p.append(mewl[n - 1][j])
					break
			elif mewl[i][j] != p[-1]:
				p.append(mewl[i][j])
				break
	s = ''
	for i in p:
		s += str(i) + ' '
	return s
so = []
a = int(input())
for i in range(a):
	n = int(input())
	so.append(fu(n, list(map(int, input().rstrip().split())), list(map(int, input().rstrip().split())), list(map(int, input().rstrip().split()))))
for i in so:
	print(i)


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	r = list(zip(a, b, c))
	v = [0]
	for i in range(0, n):
		(x, y, z) = r[i]
		v.append([x, y][x == v[-1]])
	if v[1] == v[-1]:
		(x, y, z) = r[-1]
		p = v[-2]
		f = v[1]
		v[-1] = [[x, y][y != p and y != f], z][z != p and z != f]
	print(*v[1:])


import math
import sys

class Graph:

	def __init__(self, Nodes, is_directed=False):
		self.nodes = Nodes
		self.adj_list = {}
		self.is_directed = is_directed
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, u, v):
		self.adj_list[u].append(v)
		if self.is_directed == False:
			self.adj_list[v].append(u)

	def print_graph(self):
		for node in self.nodes:
			print(node, '->', self.adj_list[node])

	def degree_node(self, node):
		return len(self.adj_list[node])

	def dfsUTIL(self, v, visited, parents=[]):
		visited[v] = True
		for i in self.adj_list[v]:
			if visited[i] == False:
				self.dfsUTIL(i, visited, parents)
				parents.append(i)

	def dfs(self, v):
		visited = [False] * (max(self.adj_list) + 1)
		parents = [v]
		self.dfsUTIL(v, visited, parents)
		return len(parents)

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

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

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(x, a, b, c):
	return a * x * x + b * x + c

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	a = inp()
	b = inp()
	c = inp()
	ls = [0] * n
	ls[0] = c[0]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != ls[0] and a[i] != ls[i - 1]:
				ls[i] = a[i]
			elif b[i] != ls[0] and b[i] != ls[i - 1]:
				ls[i] = b[i]
			elif c[i] != ls[0] and c[i] != ls[i - 1]:
				ls[i] = c[i]
		elif ls[i - 1] != a[i]:
			ls[i] = a[i]
		elif ls[i - 1] != b[i]:
			ls[i] = b[i]
		elif ls[i - 1] != c[i]:
			ls[i] = c[i]
	for i in ls:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip(' ').split(' ')))
	b = list(map(int, input().strip(' ').split(' ')))
	c = list(map(int, input().strip(' ').split(' ')))
	d = [0] * n
	d[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != d[i - 1]:
			d[i] = a[i]
		elif b[i] != d[i - 1]:
			d[i] = b[i]
		else:
			d[i] = c[i]
	if a[n - 1] != d[n - 2] and a[n - 1] != d[0]:
		d[n - 1] = a[n - 1]
	elif b[n - 1] != d[n - 2] and b[n - 1] != d[0]:
		d[n - 1] = b[n - 1]
	else:
		d[n - 1] = c[n - 1]
	print(*d)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(map(int, input().split()))
	ans = [-1 for i in range(n)]
	ans[0] = arr[0]
	for i in range(1, n - 1):
		if arr[i] != ans[i - 1]:
			ans[i] = arr[i]
		elif brr[i] != ans[i - 1]:
			ans[i] = brr[i]
		else:
			ans[i] = crr[i]
	if arr[n - 1] != ans[n - 2] and arr[n - 1] != ans[0]:
		ans[n - 1] = arr[n - 1]
	elif brr[n - 1] != ans[n - 2] and brr[n - 1] != ans[0]:
		ans[n - 1] = brr[n - 1]
	else:
		ans[n - 1] = crr[n - 1]
	print(*ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	r = a.copy()
	for i in range(1, n):
		if r[i] == r[i - 1]:
			if r[i] != b[i]:
				r[i] = b[i]
			else:
				r[i] = c[i]
	if r[0] == r[-1]:
		if a[-1] != r[0] and a[-1] != r[-2]:
			r[-1] = a[-1]
		elif b[-1] != r[0] and b[-1] != r[-2]:
			r[-1] = b[-1]
		else:
			r[-1] = c[-1]
	print(*r)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = [LI() for _ in range(3)]
		r = [a[0][0]]
		for i in range(1, n - 1):
			t = r[-1]
			for j in range(3):
				if a[j][i] != t:
					r.append(a[j][i])
					break
		t = r[-1]
		u = r[0]
		for j in range(3):
			s = a[j][-1]
			if s != t and s != u:
				r.append(s)
				break
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	a = list(mints())
	b = list(mints())
	c = list(mints())
	a.append(a[0])
	b.append(b[0])
	c.append(c[0])
	r = [0] * n
	r[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != r[i - 1]:
			r[i] = a[i]
		elif b[i] != r[i - 1]:
			r[i] = b[i]
		else:
			r[i] = c[i]
	if a[n - 1] != r[0] and a[n - 1] != r[n - 2]:
		r[n - 1] = a[n - 1]
	elif b[n - 1] != r[0] and b[n - 1] != r[n - 2]:
		r[n - 1] = b[n - 1]
	else:
		r[n - 1] = c[n - 1]
	print(' '.join(map(str, r)))
for i in range(mint()):
	solve()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = LI()
	bb = LI()
	cc = LI()
	ans = [aa[0]]
	for (a, b) in zip(aa[1:], bb[1:]):
		if ans[-1] == a:
			ans.append(b)
		else:
			ans.append(a)
	if ans[0] == ans[-1] or ans[-1] == ans[-2]:
		ans[-1] = aa[-1]
	if ans[0] == ans[-1] or ans[-1] == ans[-2]:
		ans[-1] = bb[-1]
	if ans[0] == ans[-1] or ans[-1] == ans[-2]:
		ans[-1] = cc[-1]
	print(*ans)


from sys import stdin
T = int(stdin.readline().strip())
for caso in range(T):
	n = int(stdin.readline().strip())
	s1 = list(map(int, stdin.readline().strip().split()))
	s2 = list(map(int, stdin.readline().strip().split()))
	s3 = list(map(int, stdin.readline().strip().split()))
	ans = [-1 for i in range(n)]
	for i in range(n):
		x = -1
		if ans[(i - 1) % n] != s1[i] and ans[(i + 1) % n] != s1[i]:
			x = s1[i]
		if ans[(i - 1) % n] != s2[i] and ans[(i + 1) % n] != s2[i]:
			x = s2[i]
		if ans[(i - 1) % n] != s3[i] and ans[(i + 1) % n] != s3[i]:
			x = s3[i]
		ans[i] = x
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = [a[0]]
	for i in range(1, n - 1):
		if a[i] != res[-1]:
			res.append(a[i])
		else:
			res.append(b[i])
	if res[-1] != a[-1] and res[0] != a[-1]:
		res.append(a[-1])
	elif res[-1] != b[-1] and res[0] != b[-1]:
		res.append(b[-1])
	else:
		res.append(c[-1])
	for i in res:
		print(i, end=' ')
	print()


testCases = int(input())
for j in range(0, testCases):
	n = int(input())
	a = input().split(' ')
	for i in range(0, len(a)):
		a[i] = int(a[i])
	b = input().split(' ')
	for i in range(0, len(a)):
		b[i] = int(b[i])
	c = input().split(' ')
	for i in range(0, len(a)):
		c[i] = int(c[i])
	newlist = []
	newlist.append(a[0])
	for i in range(1, n - 1):
		if newlist[i - 1] == a[i]:
			newlist.append(b[i])
		else:
			newlist.append(a[i])
	if a[n - 1] != newlist[0] and a[n - 1] != newlist[n - 2]:
		newlist.append(a[n - 1])
	elif b[n - 1] != newlist[0] and b[n - 1] != newlist[n - 2]:
		newlist.append(b[n - 1])
	else:
		newlist.append(c[n - 1])
	printString = ''
	for i in range(0, len(newlist)):
		printString += str(newlist[i]) + ' '
	print(printString)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
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 binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

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

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def reVal(num):
	if num >= 0 and num <= 9:
		return chr(num + ord('0'))
	else:
		return chr(num - 10 + ord('A'))

def strev(str):
	len = len(str)
	for i in range(int(len / 2)):
		temp = str[i]
		str[i] = str[len - i - 1]
		str[len - i - 1] = temp

def fromDeci(res, base, inputNum):
	index = 0
	while inputNum > 0:
		res += reVal(inputNum % base)
		inputNum = int(inputNum / base)
	res = res[::-1]
	return res

def norm(s, l):
	tba = '0' * (l - len(s))
	return tba + s
for xyz in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	cl = a
	i = 1
	while i < n:
		if ans[i - 1] == a[i]:
			ans.append(b[i])
		else:
			ans.append(a[i])
		i += 1
	if a[0] == ans[-1]:
		ans.pop()
		(e1, e2) = (ans[0], ans[-1])
		if e1 != a[-1] and e2 != a[-1]:
			ans.append(a[-1])
		elif e1 != b[-1] and e2 != b[-1]:
			ans.append(b[-1])
		else:
			ans.append(c[-1])
	print(*ans)


for t in range(int(input())):
	l = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	ans.append(a[0])
	for i in range(1, l - 1):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		elif b[i] != ans[i - 1]:
			ans.append(b[i])
		elif c[i] != ans[i - 1]:
			ans.append(c[i])
	if l != 1:
		if a[l - 1] != ans[l - 2] and a[l - 1] != ans[0]:
			ans.append(a[l - 1])
		elif b[l - 1] != ans[l - 2] and b[l - 1] != ans[0]:
			ans.append(b[l - 1])
		elif c[l - 1] != ans[l - 2] and c[l - 1] != ans[0]:
			ans.append(c[l - 1])
	print(*ans, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	f = []
	if a[0] != a[1] or a[0] != b[1] or a[0] != c[1]:
		if a[0] != a[n - 1] or a[0] != b[n - 1] or a[0] != c[n - 1]:
			f.append(a[0])
	elif b[0] != a[1] or b[0] != b[1] or b[0] != c[1]:
		if a[0] != a[n - 1] or a[0] != b[n - 1] or a[0] != c[n - 1]:
			f.append(b[0])
	elif c[0] != a[1] or c[0] != b[1] or c[0] != c[1]:
		if c[0] != a[n - 1] or c[0] != b[n - 1] or c[0] != c[n - 1]:
			f.append(c[0])
	val = f[0]
	for j in range(1, n):
		if j == n - 1:
			if a[j] != f[j - 1] and a[j] != val:
				if a[j] != a[(j + 1) % n] or a[j] != b[(j + 1) % n] or a[j] != c[(j + 1) % n]:
					f.append(a[j])
					continue
			if b[j] != f[j - 1] and b[j] != val:
				if b[j] != a[(j + 1) % n] or b[j] != b[(j + 1) % n] or b[j] != c[(j + 1) % n]:
					f.append(b[j])
					continue
			if c[j] != f[j - 1] and c[j] != val:
				if c[j] != a[(j + 1) % n] or c[j] != b[(j + 1) % n] or c[j] != c[(j + 1) % n]:
					f.append(c[j])
					continue
		elif a[j] != f[j - 1]:
			if a[j] != f[j - 1] and a[j] != val:
				if a[j] != a[j + 1] or a[j] != b[j + 1] or a[j] != c[j + 1]:
					f.append(a[j])
					continue
		if b[j] != f[j - 1]:
			if b[j] != f[j - 1] and b[j] != val:
				if b[j] != a[j + 1] or b[j] != b[j + 1] or b[j] != c[j + 1]:
					f.append(b[j])
					continue
		if c[j] != f[j - 1]:
			if c[j] != f[j - 1] and c[j] != val:
				if c[j] != a[j + 1] or c[j] != b[j + 1] or c[j] != c[j + 1]:
					f.append(c[j])
					continue
	print(*f)


from collections import defaultdict, Counter
from math import log, ceil, floor
from itertools import accumulate

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	prev = a[0]
	ans = [prev]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != prev:
				curr = a[i]
			elif b[i] != prev:
				curr = b[i]
			else:
				curr = c[i]
			ans.append(curr)
			prev = curr
		elif a[i] != a[0] and a[i] != prev:
			ans.append(a[i])
		elif b[i] != a[0] and b[i] != prev:
			ans.append(b[i])
		elif c[i] != a[0] and c[i] != prev:
			ans.append(c[i])
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


def solve(n, a, b, c):
	res = []
	res.append(a[0])
	index = 1
	for i in range(1, n - 1):
		if res[index - 1] != a[index]:
			res.append(a[index])
		elif res[index - 1] != b[index]:
			res.append(b[index])
		else:
			res.append(c[index])
		index += 1
	if res[n - 2] != a[n - 1] and a[n - 1] != res[0]:
		res.append(a[n - 1])
	elif res[n - 2] != b[n - 1] and b[n - 1] != res[0]:
		res.append(b[n - 1])
	else:
		res.append(c[n - 1])
	print(' '.join(map(str, res)))
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	solve(n, a, b, c)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = [int(x) for x in input().split()]
		B = [int(x) for x in input().split()]
		C = [int(x) for x in input().split()]
		ans = []
		for i in range(N):
			if i == 0:
				ans.append(A[i])
			elif i == N - 1:
				if ans[-1] != A[i] and ans[0] != A[i]:
					ans.append(A[i])
				elif ans[-1] != B[i] and ans[0] != B[i]:
					ans.append(B[i])
				else:
					ans.append(C[i])
			elif ans[-1] != A[i]:
				ans.append(A[i])
			elif ans[-1] != B[i]:
				ans.append(B[i])
			else:
				ans.append(C[i])
		print(*ans)
main()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		ans = [a[0]]
		for i in range(1, n - 1):
			if a[i] != ans[-1]:
				ans.append(a[i])
			elif b[i] != ans[-1]:
				ans.append(b[i])
			elif c[i] != ans[-1]:
				ans.append(c[i])
		if a[-1] != ans[-1] and a[-1] != ans[0]:
			ans.append(a[-1])
		elif b[-1] != ans[-1] and b[-1] != ans[0]:
			ans.append(b[-1])
		elif c[-1] != ans[-1] and c[-1] != ans[0]:
			ans.append(c[-1])
		print(' '.join(map(str, 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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	res = [None] * n
	for i in range(n):
		res[i] = next((k for k in (a[i], b[i], c[i]) if k != res[(i + 1) % n] and k != res[(i - 1) % n]))
	print(*res)


from typing import List

def solve(a: List[int], b: List[int], c: List[int]) -> str:
	ans = str(a[0]) + ' '
	ans_arr = [a[0]]
	for i in range(1, len(a)):
		if i == len(a) - 1:
			if a[i] != ans_arr[-1] and a[i] != ans_arr[0]:
				ans += str(a[i]) + ' '
				ans_arr.append(a[i])
			elif b[i] != ans_arr[-1] and b[i] != ans_arr[0]:
				ans += str(b[i]) + ' '
				ans_arr.append(b[i])
			else:
				ans += str(c[i]) + ' '
				ans_arr.append(c[i])
		elif a[i] != ans_arr[-1]:
			ans += str(a[i]) + ' '
			ans_arr.append(a[i])
		elif b[i] != ans_arr[-1]:
			ans += str(b[i]) + ' '
			ans_arr.append(b[i])
		else:
			ans += str(c[i]) + ' '
			ans_arr.append(c[i])
	return ans[:-1]
test_cases = int(input())
for _ in range(test_cases):
	N = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	print(solve(a, b, c))


import sys, math
import io, os
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	a = [mdata() for i in range(3)]
	l = [a[0][0]]
	for i in range(1, n):
		for j in range(3):
			if a[j][i] != l[-1]:
				l.append(a[j][i])
				break
	if l[0] == l[-1] and n > 1:
		for j in range(3):
			if a[j][-1] != l[-1] and a[j][-1] != l[-2]:
				l[-1] = a[j][-1]
				break
	outl(l)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	prev = a[0]
	print(prev, end=' ')
	f = a[0]
	for i in range(1, n):
		if i == n - 1:
			if prev != a[i] and a[i] != f:
				prev = a[i]
				print(prev, end=' ')
			elif prev != b[i] and b[i] != f:
				prev = b[i]
				print(prev, end=' ')
			elif prev != c[i] and c[i] != f:
				prev = c[i]
				print(prev, end=' ')
			continue
		if prev != a[i]:
			prev = a[i]
			print(prev, end=' ')
		elif prev != b[i]:
			prev = b[i]
			print(prev, end=' ')
		elif prev != c[i]:
			prev = c[i]
			print(prev, end=' ')
	print()


n = int(input())
for i in range(n):
	s = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	if a[0] != b[1] or a[0] != c[1] or a[0] != a[1]:
		p.append(a[0])
	elif b[0] != b[1] or b[0] != c[1] or b[0] != a[1]:
		p.append(b[0])
	elif c[0] != b[1] or c[0] != c[1] or c[0] != a[1]:
		p.append(c[0])
	for i in range(1, len(a) - 1):
		if a[i] != p[i - 1] and (a[i] != a[i + 1] or a[i] != b[i + 1] or a[i] != c[i + 1]):
			p.append(a[i])
		elif b[i] != p[i - 1] and (b[i] != a[i + 1] or b[i] != b[i + 1] or b[i] != c[i + 1]):
			p.append(b[i])
		elif c[i] != p[i - 1] and (c[i] != a[i + 1] or c[i] != b[i + 1] or c[i] != c[i + 1]):
			p.append(c[i])
	if a[s - 1] != p[s - 2] and a[s - 1] != p[0]:
		p.append(a[s - 1])
	elif b[s - 1] != p[s - 2] and b[s - 1] != p[0]:
		p.append(b[s - 1])
	elif c[s - 1] != p[s - 2] and c[s - 1] != p[0]:
		p.append(c[s - 1])
	print(*p)


m = int(input())
l = []
for i in range(m):
	t = int(input())
	a = []
	for i in range(3):
		a.append(input().split())
	s = [a[0][0]]
	for i in range(1, t):
		b = s[-1]
		if i != t - 1:
			if b != a[0][i]:
				s.append(a[0][i])
			elif b != a[1][i]:
				s.append(a[1][i])
			else:
				s.append(a[2][i])
		elif s[0] != a[0][i] and s[-1] != a[0][i]:
			s.append(a[0][i])
		elif s[0] != a[1][i] and s[-1] != a[1][i]:
			s.append(a[1][i])
		else:
			s.append(a[2][i])
	l.append(' '.join(s))
for i in l:
	print(i)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	g = [a[0]]
	k = a[0]
	for j in range(1, n - 1):
		if a[j] == k:
			g.append(b[j])
			k = b[j]
		else:
			g.append(a[j])
			k = a[j]
	if b[n - 1] != k and a[0] != b[n - 1]:
		g.append(b[n - 1])
	elif a[n - 1] != k and a[0] != a[n - 1]:
		g.append(a[n - 1])
	else:
		g.append(c[n - 1])
	print(' '.join(map(str, g)))


t = int(input())
ans = []
for k in range(t):
	n = int(input())
	arr = []
	for j in range(3):
		a = list(map(int, input().split()))
		arr.append(a)
	p = []
	p.append(arr[0][0])
	for i in range(1, n - 1):
		if arr[0][i] != p[i - 1]:
			p.append(arr[0][i])
		elif arr[1][i] != p[i - 1]:
			p.append(arr[1][i])
		else:
			p.append(arr[2][i])
	if arr[0][n - 1] != p[0] and arr[0][n - 1] != p[n - 2]:
		p.append(arr[0][n - 1])
	elif arr[1][n - 1] != p[0] and arr[1][n - 1] != p[n - 2]:
		p.append(arr[1][n - 1])
	else:
		p.append(arr[2][n - 1])
	ans.append(p)
for m in ans:
	print(*m)


[(lambda N, a, b, c, p: [[p.append(i if p[-1] != i else j) for (i, j) in zip(a, b)], p.__setitem__(N, a[N - 1] if a[N - 1] != p[N - 1] and a[N - 1] != p[1] else b[N - 1] if b[N - 1] != p[N - 1] and b[N - 1] != p[1] else c[N - 1]), print(*p[1:])])(int(input()), *[list(map(int, input().split())) for i in '000'], [0]) for t in range(int(input()))]


for z in range(int(input())):
	n = int(input())
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	c = tuple(map(int, input().split()))
	p = []
	prev = a[n - 1]
	for i in range(n):
		for j in (a[i], b[i], c[i]):
			if j != prev:
				prev = j
				p.append(j)
				break
	if p[0] == p[-1]:
		for j in (a[-1], b[-1], c[-1]):
			if j != p[0] and j != p[-2]:
				p[-1] = j
				break
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(3):
		a.append(list(map(int, input().split())))
	d = -1
	sol = []
	for i in range(n - 1):
		for j in range(3):
			if a[j][i] != d:
				sol.append(a[j][i])
				d = a[j][i]
				break
	for j in range(3):
		if a[j][n - 1] not in [sol[0], sol[-1]]:
			sol.append(a[j][n - 1])
			break
	print(' '.join([str(i) for i in sol]))


T = int(input(''))
for _ in range(T):
	n = int(input(''))
	a = list(map(int, input('').split(' ')))
	b = list(map(int, input('').split(' ')))
	c = list(map(int, input('').split(' ')))
	p = list()
	current = 'a'
	current_list = a
	p.append(current_list[0])
	for i in range(1, n):
		if p[i - 1] != current_list[i]:
			p.append(current_list[i])
		else:
			if current == 'a':
				current_list = b
				current = 'b'
			elif current == 'b':
				current_list = c
				current = 'c'
			elif current == 'c':
				current_list = a
				current = 'a'
			p.append(current_list[i])
	x = set([p[0], p[-2]])
	y = set([a[-1], b[-1], c[-1]])
	m = y.difference(x)
	p[-1] = list(m)[0]
	print(*p)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	temp = a[0]
	for i in range(1, n):
		d = []
		d.append(a[i])
		d.append(b[i])
		d.append(c[i])
		for j in range(3):
			if i < n - 1:
				if d[j] != temp:
					temp = d[j]
					break
			elif i == n - 1:
				if d[j] != p[0] and d[j] != temp:
					temp = d[j]
					break
		p.append(temp)
	for char in p:
		print(char, end=' ')
	print()
	t -= 1


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
import random
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [-1]
	for i in range(n):
		if i == n - 1:
			if ans[-1] != a[i] and ans[1] != a[i]:
				ans.append(a[i])
			elif ans[-1] != b[i] and ans[1] != b[i]:
				ans.append(b[i])
			else:
				ans.append(c[i])
			continue
		if ans[-1] != a[i]:
			ans.append(a[i])
		elif ans[-1] != b[i]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	print(*ans[1:])


for _ in range(int(input())):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	b = [0] + list(map(int, input().split()))
	c = [0] + list(map(int, input().split()))
	p = [0, a[1]]
	for i in range(2, n + 1):
		x = [a[i], b[i], c[i]]
		if i != n:
			for each in x:
				if each != p[i - 1]:
					p.append(each)
					break
		else:
			for each in x:
				if each != p[1] and each != p[i - 1]:
					p.append(each)
					break
	print(*p[1:])


cases = int(input())
for _ in range(cases):
	n = int(input())
	s = set()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	curr_state = 0
	p = []
	for i in range(len(a)):
		if a[i] != curr_state:
			p.append(a[i])
			curr_state = a[i]
		elif b[i] != curr_state:
			p.append(b[i])
			curr_state = b[i]
		else:
			p.append(c[i])
			curr_state = c[i]
	if p[0] == p[-1]:
		l1 = a[-1]
		l2 = b[-1]
		l3 = c[-1]
		if p[0] != l1 and p[-2] != l1:
			p[-1] = l1
		if p[0] != l2 and p[-2] != l2:
			p[-1] = l2
		if p[0] != l3 and p[-2] != l3:
			p[-1] = l3
	print(*p)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	e = [a[0]]
	for i in range(1, n):
		if e[i - 1] != a[i]:
			e.append(a[i])
		else:
			e.append(b[i])
	if e[0] != e[-1]:
		print(*e)
	else:
		e[-1] = b[-1]
		if e[-1] == e[-2] or e[-1] == e[0]:
			e[-1] = c[-1]
		print(*e)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = []
	(l1, l2, l3) = (1, 0, 0)
	cnt = 1
	i = 1
	l.append(a[0])
	while cnt < n - 1:
		if l1:
			if a[i] != l[-1]:
				l.append(a[i])
				cnt += 1
				i += 1
			else:
				l1 = 0
				l2 = 1
				l3 = 0
		if l2:
			if b[i] != l[-1]:
				l.append(b[i])
				cnt += 1
				i += 1
			else:
				l1 = 0
				l2 = 0
				l3 = 1
		if l3:
			if c[i] != l[-1]:
				l.append(c[i])
				cnt += 1
				i += 1
			else:
				l1 = 1
				l2 = 0
				l3 = 0
	while cnt < n:
		if l1:
			if a[i] != l[-1] and l[0] != a[i]:
				l.append(a[i])
				cnt += 1
				i += 1
			else:
				l1 = 0
				l2 = 1
				l3 = 0
		if l2:
			if b[i] != l[-1] and l[0] != b[i]:
				l.append(b[i])
				cnt += 1
				i += 1
			else:
				l1 = 0
				l2 = 0
				l3 = 1
		if l3:
			if c[i] != l[-1] and l[0] != c[i]:
				l.append(c[i])
				cnt += 1
				i += 1
			else:
				l1 = 1
				l2 = 0
				l3 = 0
	print(*l)


from sys import stdin, stdout
import math, bisect
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	return ' '.join(list(map(str, a)))

def solve():
	n = I()
	a = L()
	b = L()
	c = L()
	p = [a[0]]
	for i in range(1, n - 1):
		if a[i] == p[i - 1]:
			p += [b[i]]
		else:
			p += [a[i]]
	if a[-1] != p[0] and a[-1] != p[-1]:
		p += [a[-1]]
	elif b[-1] != p[0] and b[-1] != p[-1]:
		p += [b[-1]]
	else:
		p += [c[-1]]
	print(*p)
for _ in range(I()):
	solve()


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	b = Read.list_int()
	c = Read.list_int()
	p = [str(a[0])]
	for i in range(n - 1):
		if p[i] != str(a[i + 1]):
			p.append(str(a[i + 1]))
		elif p[i] != str(b[i + 1]):
			p.append(str(b[i + 1]))
		else:
			p.append(str(c[i + 1]))
	if p[-1] == p[0]:
		if str(a[-1]) != p[-1] and str(a[-1]) != p[-2]:
			p[-1] = str(a[-1])
		elif str(b[-1]) != p[-1] and str(b[-1]) != p[-2]:
			p[-1] = str(b[-1])
		else:
			p[-1] = str(c[-1])
	print(' '.join(p))
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


a = int(input())
for i in range(a):
	x = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	ans = [a1[0]]
	for i in range(1, x):
		if i == x - 1:
			if a1[i] != ans[0] and a1[i] != ans[-1]:
				ans.append(a1[i])
			elif a2[i] != ans[0] and a2[i] != ans[-1]:
				ans.append(a2[i])
			else:
				ans.append(a3[i])
			continue
		if a1[i] == ans[-1]:
			ans.append(a2[i])
		else:
			ans.append(a1[i])
	print(*ans)


def solve():
	n = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	ans = [None]
	for i in range(n - 1):
		for elem in [A[i], B[i], C[i]]:
			if elem != ans[-1]:
				ans.append(elem)
				break
	for elem in [A[-1], B[-1], C[-1]]:
		if elem != ans[-1] and elem != ans[1]:
			ans.append(elem)
			break
	print(*ans[1:])
for _ in range(int(input())):
	solve()


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n,) = R()
	(f, *a) = zip(R(), R(), R())
	r = [f[0]]
	i = 1
	for t in a:
		i += 1
		r += (({*t} - {r[-1], (r[0], 0)[i < n]}).pop(),)
	print(*r)


(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	Z = list(map(int, input().split()))
	b = 0
	R = []
	for i in range(N):
		if i != N - 1:
			if X[i] != b:
				R.append(X[i])
				b = X[i]
			elif Y[i] != b:
				R.append(Y[i])
				b = Y[i]
		elif X[i] != b and X[i] != R[0]:
			R.append(X[i])
		elif Y[i] != b and Y[i] != R[0]:
			R.append(Y[i])
		else:
			R.append(Z[i])
	print(*R)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	j = 1
	while j < n:
		if a[j] == ans[-1]:
			ans.append(b[j])
		else:
			ans.append(a[j])
		j += 1
	ans[-1] = a[-1]
	if ans[-1] != ans[0] and ans[-1] != ans[-2]:
		pass
	else:
		ans[-1] = b[-1]
		if ans[-1] != ans[0] and ans[-1] != ans[-2]:
			pass
		else:
			ans[-1] = c[-1]
	print(*ans)


t = int(input())
for _ in range(t):
	ans = []
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	ans.append(a[0])
	for i in range(1, n - 1):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		elif b[i] != ans[i - 1]:
			ans.append(b[i])
	if a[-1] != ans[0] and a[-1] != ans[-1]:
		ans.append(a[-1])
	elif b[-1] != ans[0] and b[-1] != ans[-1]:
		ans.append(b[-1])
	elif c[-1] != ans[0] and c[-1] != ans[-1]:
		ans.append(c[-1])
	for x in ans:
		print(x, end=' ')
	print()


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	for i in range(n):
		for x in (a[i], b[i], c[i]):
			if ans[i - 1] != x != ans[(i + 1) % n]:
				ans[i] = x
	print(*ans)


a = int(input())
for i in range(a):
	b = int(input())
	c1 = list(map(int, input().split()))
	c2 = list(map(int, input().split()))
	c3 = list(map(int, input().split()))
	d = c1[0]
	print(d, end=' ')
	for j in range(1, b - 1):
		if c1[j] != d:
			d = c1[j]
		elif c2[j] != d:
			d = c2[j]
		else:
			d = c3[j]
		print(d, end=' ')
	if c1[-1] != d and c1[-1] != c1[0]:
		d = c1[-1]
	elif c2[-1] != d and c2[-1] != c1[0]:
		d = c2[-1]
	else:
		d = c3[-1]
	print(d)


def find(arr, i, l, answer):
	if i == len(arr[0]):
		for i in range(len(answer)):
			answer[i] = l[i]
		return True
	for k in range(3):
		if len(l) == 0:
			if find(arr, i + 1, l + [arr[k][i]], answer):
				return True
		elif i < len(arr[0]) - 1 and l[-1] != arr[k][i]:
			if find(arr, i + 1, l + [arr[k][i]], answer):
				return True
		elif i == len(arr[0]) - 1 and l[0] != arr[k][i] and (l[-1] != arr[k][i]):
			if find(arr, i + 1, l + [arr[k][i]], answer):
				return True
	return False
for _ in range(int(input())):
	n = int(input())
	arr = []
	arr.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
	answer = [0] * n
	find(arr, 0, [], answer)
	print(*answer)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().lstrip().split()))
	b = list(map(int, input().lstrip().split()))
	c = list(map(int, input().lstrip().split()))
	p = a
	for i in range(n - 1):
		if p[i] == p[i + 1]:
			p[i + 1] = b[i + 1]
		if p[i] == p[i + 1]:
			p[i + 1] = c[i + 1]
	if p[n - 1] == p[0]:
		p[n - 1] = b[n - 1]
	if p[n - 1] == p[0] or p[n - 1] == p[n - 2]:
		p[n - 1] = c[n - 1]
	for i in range(n - 1):
		print(p[i], end=' ')
	print(p[n - 1])


test = int(input())
for t in range(test):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	curr = -1
	for i in range(n - 1):
		if int(a[i]) != curr:
			print(a[i], end=' ')
			curr = int(a[i])
		elif int(b[i]) != curr:
			print(b[i], end=' ')
			curr = int(b[i])
		elif int(c[i]) != curr:
			print(c[i], end=' ')
			curr = int(c[i])
	if int(a[n - 1]) != curr and int(a[n - 1]) != int(a[0]):
		print(a[n - 1])
	elif int(b[n - 1]) != curr and int(b[n - 1]) != int(a[0]):
		print(b[n - 1])
	elif int(c[n - 1]) != curr and int(c[n - 1]) != int(a[0]):
		print(c[n - 1])


def generate_required_sequence(n: int, sequence1: list, sequence2: list, sequence3: list) -> str:
	resultant_sequence = list()
	for (index, v) in enumerate(zip(sequence1, sequence2, sequence3)):
		if not index:
			resultant_sequence.append(v[0])
			continue
		if resultant_sequence[0] != v[0] and resultant_sequence[index - 1] != v[0]:
			resultant_sequence.append(v[0])
			continue
		if resultant_sequence[0] != v[1] and resultant_sequence[index - 1] != v[1]:
			resultant_sequence.append(v[1])
			continue
		resultant_sequence.append(v[2])
	return ' '.join(list(map(str, resultant_sequence)))

def main():
	for _ in range(int(input().strip())):
		print(generate_required_sequence(int(input().strip()), list(map(int, input().strip().split())), list(map(int, input().strip().split())), list(map(int, input().strip().split()))))
main()


for tc in range(int(input())):
	n = int(input())
	a = list(input().split())
	b = list(input().split())
	c = list(input().split())
	s = [(a[i], b[i], c[i]) for i in range(n)]
	ans = [a[0]]
	for i in range(1, n):
		for j in range(3):
			if s[i][j] != ans[0] and s[i][j] != ans[-1]:
				ans.append(s[i][j])
				break
	print(' '.join(ans))


t = int(input())

def circle(A, B, C, n):
	Ans = []
	for i in range(n):
		if i == 0:
			Ans.append(A[0])
		elif i < n - 1:
			if A[i] == Ans[-1]:
				Ans.append(B[i])
			else:
				Ans.append(A[i])
		elif A[n - 1] != Ans[-1] and A[n - 1] != Ans[0]:
			Ans.append(A[i])
		elif B[n - 1] != Ans[-1] and B[n - 1] != Ans[0]:
			Ans.append(B[i])
		else:
			Ans.append(C[n - 1])
	return Ans
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	print(*circle(A, B, C, n))


for _ in range(int(input())):
	n = int(input())
	a = [int(num) for num in input().split(' ')]
	b = [int(num) for num in input().split(' ')]
	c = [int(num) for num in input().split(' ')]
	arr = []
	for i in range(n - 1):
		arr.append([a[i], b[i]])
	ans = ['*'] * n
	ans[0] = arr[0][0]
	for i in range(1, n - 1):
		if arr[i][0] == ans[i - 1]:
			ans[i] = arr[i][1]
		else:
			ans[i] = arr[i][0]
	if a[-1] != ans[-2] and a[-1] != ans[0]:
		ans[-1] = a[-1]
	elif b[-1] != ans[-2] and b[-1] != ans[0]:
		ans[-1] = b[-1]
	else:
		ans[-1] = c[-1]
	for item in ans:
		print(item, end=' ')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	ans = [arr1[0]]
	for j in range(1, n):
		if arr1[j] != ans[j - 1]:
			ans.append(arr1[j])
		elif arr1[j] == ans[j - 1] and arr2[j] != ans[j - 1]:
			ans.append(arr2[j])
		else:
			ans.append(arr3[j])
	if ans[0] == ans[-1]:
		if arr1[-1] != ans[0] and arr1[-1] != ans[-2]:
			ans[-1] = arr1[-1]
		elif arr2[-1] != ans[0] and arr2[-1] != ans[-2]:
			ans[-1] = arr2[-1]
		else:
			ans[-1] = arr3[-1]
	print(*ans)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [None] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		p[i] = ({a[i], b[i]} - {p[i - 1]}).pop()
	p[n - 1] = ({a[n - 1], b[n - 1], c[n - 1]} - {p[0], p[n - 2]}).pop()
	print(' '.join(map(str, p)))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		s = [0] * n
		s[0] = a[0]
		for i in range(1, n - 1):
			if a[i] != s[i - 1]:
				s[i] = a[i]
			elif b[i] != s[i - 1]:
				s[i] = b[i]
			elif c[i] != s[i - 1]:
				s[i] = c[i]
		if a[-1] != s[-2] and a[-1] != s[0]:
			s[-1] = a[-1]
		elif b[-1] != s[-2] and b[-1] != s[0]:
			s[-1] = b[-1]
		elif c[-1] != s[-2] and c[-1] != s[0]:
			s[-1] = c[-1]
		print(*s, sep=' ')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = a[:]
	for i in range(1, n):
		for x in (a[i], b[i], c[i]):
			if x != d[i - 1]:
				d[i] = x
				break
	for x in (a[-1], b[-1], c[-1]):
		if x != d[-2] and x != d[0]:
			d[-1] = x
			break
	print(*d)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(a[0], end=' ')
	p = a[0]
	s = a[0]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != p and a[i] != s:
				print(a[i])
			elif b[i] != p and b[i] != s:
				print(b[i])
			else:
				print(c[i])
		elif a[i] != p:
			print(a[i], end=' ')
			p = a[i]
		elif b[i] != p:
			print(b[i], end=' ')
			p = b[i]
		else:
			print(c[i], end=' ')
			p = c[i]
for _ in range(int(input())):
	solve()


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		A = arrinp()
		B = arrinp()
		C = arrinp()
		P = [-1 for i in range(n)]
		i = 1
		P[0] = A[0]
		k = 1

		def select(x, k):
			if x == 0:
				return A[k]
			elif x == 1:
				return B[k]
			elif x == 2:
				return C[k]
		while i < n and k < n:
			x = 0
			while x < 3 and P[i - 1] == select(x, k):
				x += 1
			P[i] = select(x, k)
			i += 1
			k += 1
		x = 0
		k -= 1
		while P[-1] == P[0] or P[-1] == P[-2]:
			P[-1] = select(x, k)
			x = int((x + 1) % 3)
		print(*P, sep=' ')
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	for i in range(n):
		l = [a[i], b[i], c[i]]
		tem = set(l)
		if i > 0 and i < n - 1:
			ll = [ans[i - 1]]
			tem1 = list(tem - set(ll))
			ans.append(tem1[0])
		elif i == n - 1:
			ll = [ans[i - 1], ans[0]]
			tem1 = list(tem - set(ll))
			ans.append(tem1[0])
		else:
			tem = list(tem)
			ans.append(tem[0])
	print(*ans)


def run(ar, ans):
	l = len(ar)
	if ar[l - 1] != ans[l - 2] and ar[l - 1] != ans[0]:
		return True
	else:
		return False
for t in range(int(input())):
	l = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	ans.append(a[0])
	for i in range(1, l - 1):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		else:
			ans.append(b[i])
	if run(a, ans):
		ans.append(a[l - 1])
	elif run(b, ans):
		ans.append(b[l - 1])
	else:
		ans.append(c[l - 1])
	print(*ans, sep=' ')


t = int(input())
while t > 0:
	n = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	print(a1[0], end=' ')
	curr = a1[0]
	for i in range(1, n - 1):
		if a1[i] != curr:
			curr = a1[i]
		elif a2[i] != curr:
			curr = a2[i]
		elif a3[i] != curr:
			curr = a3[i]
		print(curr, end=' ')
	if a1[n - 1] != a1[0] and a1[n - 1] != curr:
		print(a1[n - 1], end=' ')
	elif a2[n - 1] != a1[0] and a2[n - 1] != curr:
		print(a2[n - 1], end=' ')
	else:
		print(a3[n - 1], end=' ')
	print('')
	t -= 1


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

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

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

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

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

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	(a, b, c) = (li(), li(), li())
	ans = [a[0]] * n
	for i in range(1, n):
		prev = ans[i - 1]
		if i != n - 1:
			if prev != a[i]:
				ans[i] = a[i]
			elif prev != b[i]:
				ans[i] = b[i]
		else:
			next = ans[0]
			if prev != a[i] and next != a[i]:
				ans[i] = a[i]
			elif prev != b[i] and next != b[i]:
				ans[i] = b[i]
			elif prev != c[i] and next != c[i]:
				ans[i] = c[i]
	print(' '.join((str(i) for i in ans)))


import sys
from collections import defaultdict, Counter as CC
from math import sqrt, ceil, floor, log2
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def solve():
	(n,) = read()
	a = read()
	b = read()
	c = read()
	res = [0] * (n + 1)
	for i in range(1, n + 1):
		res[i] = a[i - 1]
		if res[i] != res[i % n + 1] and res[i] != res[i - 1]:
			continue
		res[i] = b[i - 1]
		if res[i] != res[i % n + 1] and res[i] != res[i - 1]:
			continue
		res[i] = c[i - 1]
		if res[i] != res[i % n + 1] and res[i] != res[i - 1]:
			continue
	for i in range(1, n + 1):
		print(res[i], end=' ')
	print()
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_l(tp):
	return list(r_t(tp))

def solve(A, B, C, n):
	M = [A, B, C]
	pointer = 0
	ans = [M[pointer][0]]
	for i in range(1, n):
		if M[pointer][i] == ans[-1]:
			pointer = (pointer + 1) % 3
		ans.append(M[pointer][i])
	if ans[-1] == ans[0]:
		for i in range(3):
			if M[i][-1] != ans[-2] and M[i][-1] != ans[0]:
				ans[-1] = M[i][-1]
	return ans

def main():
	cases = int(r())
	for _ in range(cases):
		n = int(r())
		A = r_l(int)
		B = r_l(int)
		C = r_l(int)
		print(*solve(A, B, C, n))
main()


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	k = 0
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(a[i])
		elif a[i] != ans[-1] and a[i] != ans[0]:
			ans.append(a[i])
		elif b[i] != ans[-1] and b[i] != ans[0]:
			ans.append(b[i])
		elif c[i] != ans[-1] and c[i] != ans[0]:
			ans.append(c[i])
	print(*ans)


def result():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	flag = 2
	ans = []
	ans.append(b[0])
	for i in range(1, n):
		if flag == 1:
			if a[i - 1] == a[i]:
				ans.append(b[i])
				flag = 2
				continue
			else:
				ans.append(a[i])
				continue
		if flag == 2:
			if b[i - 1] == b[i]:
				ans.append(c[i])
				flag = 3
				continue
			else:
				ans.append(b[i])
				continue
		if flag == 3:
			if c[i - 1] == c[i]:
				ans.append(b[i])
				flag = 2
				continue
			else:
				ans.append(c[i])
				continue
	if ans[0] == ans[n - 1]:
		if flag == 1:
			if b[n - 1] == ans[n - 2]:
				ans[n - 1] = c[n - 1]
			else:
				ans[n - 1] = b[n - 1]
		if flag == 2:
			if c[n - 1] == ans[n - 2]:
				ans[n - 1] = a[n - 1]
			else:
				ans[n - 1] = c[n - 1]
		if flag == 3:
			if a[n - 1] == ans[n - 2]:
				ans[n - 1] = b[n - 1]
			else:
				ans[n - 1] = a[n - 1]
	for i in range(n):
		print(ans[i], '', end='')
	print()
t = int(input())
while t > 0:
	result()
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = [list(map(int, input().split())) for i in range(3)]
	grid = [sorted([a[i], b[i], c[i]]) for i in range(n)]
	ans = [0] * n
	ans[0] = grid[0][0]
	for i in range(1, n):
		if grid[i][0] != ans[i - 1]:
			ans[i] = grid[i][0]
		elif grid[i][1] != ans[i - 1]:
			ans[i] = grid[i][1]
		elif grid[i][2] != ans[i - 1]:
			ans[i] = grid[i][2]
	if ans[-1] == ans[0]:
		for i in grid[-1]:
			if i != ans[0] and i != ans[-2]:
				ans[-1] = i
				break
	print(*ans)


import time
for some in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = []
	for i in range(n):
		ar = [a[i], b[i], c[i]]
		for x in ar:
			if i == 1:
				if p[len(p) - 1] != x:
					p.append(x)
					boo = False
					break
			elif i == 0:
				p.append(x)
				break
			elif i == n - 1:
				if x != p[0] and x != p[len(p) - 1]:
					p.append(x)
					break
			elif p[len(p) - 1] != x:
				p.append(x)
				boo = False
				break
	print(*p)


a = int(input())

def choosee(k1, k2, a, b, c):
	for i in [a, b, c]:
		if not (i == k1 or i == k2):
			return i

def choose(k, a, b, c):
	for i in [a, b, c]:
		if not i == k:
			return i
for i in range(a):
	b = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(map(int, input().split()))
	ans = [arr[0]]
	for i in range(1, b):
		ans.append(choose(ans[len(ans) - 1], arr[i], brr[i], crr[i]))
	ans[0] = choosee(ans[len(ans) - 1], ans[1], arr[0], brr[0], crr[0])
	print(' '.join(map(str, ans)))


def solve(n, a):
	result = [[a[j][i] for j in range(3)] for i in range(n)]
	k = []
	j = 0
	for i in range(3):
		while result[0][i] == result[-1][j]:
			j += 1
		k.append(result[0][i])
		break
	ans = [k[0]]
	for i in range(1, n - 1):
		for j in range(3):
			if ans[-1] != result[i][j]:
				ans.append(result[i][j])
				break
	for i in range(3):
		if ans[-1] != result[-1][i] and ans[0] != result[-1][i]:
			ans.append(result[-1][i])
			break
	return ans
t = int(input())
while t:
	res = []
	n = int(input())
	for _ in range(3):
		in_ = map(int, input().split())
		res.append(list(in_))
	print(*solve(n, res))
	t -= 1


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(a[0], end=' ')
	prev = a[0]
	for x in range(1, n - 1):
		if a[x] != prev:
			print(a[x], end=' ')
			prev = a[x]
		else:
			print(b[x], end=' ')
			prev = b[x]
	if a[n - 1] != a[0] and a[n - 1] != prev:
		print(a[n - 1], end=' ')
	elif b[n - 1] != a[0] and b[n - 1] != prev:
		print(b[n - 1], end=' ')
	else:
		print(c[n - 1], end=' ')
	print()
	t -= 1


from sys import stdin, stdout

def gmi():
	return map(int, stdin.readline().strip().split())

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(int, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline())

def gi():
	return int(stdin.readline())
t = gi()
while t:
	t -= 1
	n = gi()
	a = []
	a.append(gari())
	a.append(gari())
	a.append(gari())
	for i in range(1, n):
		for j in range(3):
			if a[j][i] != a[0][(i - 1) % n]:
				a[0][i] = a[j][i]
				break
	if a[0][0] == a[0][-1]:
		for i in range(3):
			if a[0][0] != a[i][-1] and a[i][-1] != a[0][-2]:
				a[0][-1] = a[i][-1]
	print(*a[0])


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	c = list(map(int, stdin.readline().rstrip().split()))
	ans = [a[0]]
	prv = a[0]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != prv:
				ans.append(a[i])
				prv = a[i]
			elif b[i] != prv:
				ans.append(b[i])
				prv = b[i]
			else:
				ans.append(c[i])
				prv = c[i]
		elif a[i] != prv and a[i] != a[0]:
			ans.append(a[i])
			prv = a[i]
		elif b[i] != prv and b[i] != a[0]:
			ans.append(b[i])
			prv = b[i]
		else:
			ans.append(c[i])
			prv = c[i]
	print(*ans)


def main():
	for _ in range(int(input())):
		n = int(input())
		(a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
		ans = [0] * n
		for i in range(n):
			for j in (a[i], b[i], c[i]):
				if ans[i - 1] != j and ans[(i + 1) % n] != j:
					ans[i] = j
					break
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = []
	p.append(a[0])
	for i in range(1, n - 1):
		t = p[i - 1]
		if t != a[i]:
			p.append(a[i])
		elif t != b[i]:
			p.append(b[i])
		else:
			p.append(c[i])
	if a[-1] != p[-1] and a[-1] != p[0]:
		p.append(a[-1])
	elif b[-1] != p[-1] and b[-1] != p[0]:
		p.append(b[-1])
	else:
		p.append(c[-1])
	sp = ' '
	for i in range(n):
		if i == n - 1:
			sp = '\n'
		print(p[i], end=sp)


t = int(input())

def full(i, history):
	global solved
	if solved:
		return
	if i == n - 1:
		print(' '.join(list(map(str, history))))
		solved = True
		return
	if history:
		last = history[-1]
	else:
		last = -1
	if a[i + 1] != last and (not (i == n - 2 and a[i + 1] == history[0])):
		full(i + 1, history + [a[i + 1]])
	if b[i + 1] != last and (not (i == n - 2 and b[i + 1] == history[0])):
		full(i + 1, history + [b[i + 1]])
	if c[i + 1] != last and (not (i == n - 2 and c[i + 1] == history[0])):
		full(i + 1, history + [c[i + 1]])
for i in range(t):
	solved = False
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	full(0, [a[0]])
	full(0, [b[0]])
	full(0, [c[0]])


def cor_val(p, m, arr, a_arr):
	if p == 0:
		return arr[0][0]
	if p == m - 1:
		return [x for x in arr[p] if x != a_arr[p - 1] and x != a_arr[0]][0]
	return [x for x in arr[p] if x != a_arr[p - 1]][0]
for test_var in range(int(input())):
	n = int(input())
	(a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
	d = zip(a, b, c)
	ls = list(d)
	ans = []
	for m in range(n):
		ans.append(cor_val(m, n, ls, ans))
	print(' '.join([str(x) for x in ans]))


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil, sqrt
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	answer = a[:]
	for i in range(1, n):
		if answer[i] == answer[i - 1]:
			answer[i] = a[i]
		if answer[i] == answer[i - 1]:
			answer[i] = b[i]
		if answer[i] == answer[i - 1]:
			answer[i] = c[i]
	if answer[0] == answer[-1]:
		if b[0] != answer[-1] and b[0] != answer[1]:
			answer[0] = b[0]
		if c[0] != answer[-1] and c[0] != answer[1]:
			answer[0] = c[0]
	print(*answer)


t = int(input())
for i in range(t):
	n = int(input())
	A = input()
	a = A.split()
	B = input()
	b = B.split()
	C = input()
	c = C.split()
	p = [0] * n
	a[0] = int(a[0])
	p[0] = a[0]
	for j in range(n):
		a[j] = int(a[j])
		b[j] = int(b[j])
		c[j] = int(c[j])
		if j != 0 and j != n - 1:
			if a[j] == p[j - 1]:
				p[j] = b[j]
			else:
				p[j] = a[j]
		elif j == n - 1:
			p[j] = a[j]
			if a[j] == p[j - 1] or a[j] == p[0]:
				p[j] = b[j]
				if b[j] == p[j - 1] or b[j] == p[0]:
					p[j] = c[j]
		print(p[j], end=' ')
	print()


import random

def l():
	return list(map(int, input().strip().split()))
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = (l(), l(), l())
	prev = -1
	ans = []
	for i in range(0, n):
		d = list([a[i], b[i], c[i]])
		p = random.choice(d)
		if prev == p:
			d.remove(p)
			p = random.choice(d)
		ans.append(p)
		prev = p
	if ans[0] == ans[-1]:
		try:
			d.remove(ans[0])
			d.remove(ans[-2])
		except:
			pass
		ans[-1] = random.choice(d)
	print(*ans)


import collections
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	out = [0 for i in range(n)]
	out[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != out[i - 1]:
			out[i] = a[i]
		elif b[i] != out[i - 1]:
			out[i] = b[i]
		else:
			out[i] = c[i]
	if a[-1] != out[0] and a[-1] != out[-2]:
		out[-1] = a[-1]
	elif b[-1] != out[0] and b[-1] != out[-2]:
		out[-1] = b[-1]
	else:
		out[-1] = c[-1]
	print(*out)


from collections import defaultdict
import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	b = get_array()
	c = get_array()
	p = [a[0]]
	for i in range(1, n - 1):
		if p[-1] != a[i]:
			p.append(a[i])
		else:
			p.append(b[i])
	if p[-1] != a[-1] and a[-1] != p[0]:
		p.append(a[-1])
	elif p[-1] != b[-1] and b[-1] != p[0]:
		p.append(b[-1])
	else:
		p.append(c[-1])
	print(*p)


def solve(M, n):
	ans = []
	prev = 0
	for j in range(n):
		for i in range(3):
			if M[i][j] != prev:
				prev = M[i][j]
				ans.append(prev)
				break
	if n >= 3:
		j = 0
		while ans[0] == ans[n - 1] or (ans[n - 2] == ans[n - 1] and j < 10):
			ans[n - 1] = M[j][n - 1]
			j += 1
	print(*ans)
for case in range(int(input())):
	n = int(input())
	mat = []
	for i in range(3):
		li = list(map(int, input().split()))
		mat.append(li)
	solve(mat, n)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def pw(a, b, md):
	result = 1
	while b > 0:
		if b % 2 == 1:
			result *= a
			result %= md
		a *= a
		a %= md
		b //= 2
	return result % md

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		br = inpt()
		cr = inpt()
		ans = [ar[0]] * n
		prev = ar[0]
		for i in range(1, n):
			if ar[i] != prev:
				prev = ar[i]
			elif br[i] != prev:
				prev = br[i]
			elif cr[i] != prev:
				prev = cr[i]
			ans[i] = prev
		(a, b, c) = (ar[n - 1], br[n - 1], cr[n - 1])
		if ans[0] == ans[n - 1]:
			if a != ans[0] and a != ans[n - 2]:
				ans[n - 1] = a
			elif b != ans[0] and b != ans[n - 2]:
				ans[n - 1] = b
			elif c != ans[0] and c != ans[n - 2]:
				ans[n - 1] = c
		print(*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')
threading.Thread(target=main).start()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	res = [arr[0]]
	for i in range(1, n - 1):
		if arr[i] != res[i - 1]:
			res.append(arr[i])
		elif b[i] != res[i - 1]:
			res.append(b[i])
		elif c[i] != res[i - 1]:
			res.append(c[i])
	for j in range(n - 1, n):
		if arr[j] != res[n - j - 1] and arr[j] != res[j - 1]:
			res.append(arr[j])
		elif b[j] != res[n - j - 1] and b[j] != res[j - 1]:
			res.append(b[j])
		elif c[j] != res[n - j - 1] and c[j] != res[j - 1]:
			res.append(c[j])
	print(*res)


from math import *
t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	lst = a[0]
	print(lst, end=' ')
	for i in range(1, n - 1):
		if lst != a[i]:
			lst = a[i]
		elif lst != b[i]:
			lst = b[i]
		elif lst != c[i]:
			lst = c[i]
		print(lst, end=' ')
	if lst != a[n - 1] and a[n - 1] != a[0]:
		lst = a[n - 1]
	elif lst != b[n - 1] and b[n - 1] != a[0]:
		lst = b[n - 1]
	elif lst != c[n - 1] and c[n - 1] != a[0]:
		lst = c[n - 1]
	print(lst, end=' ')
	print()


for query in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	y = a[0]
	print(y, end=' ')
	for z in range(1, n - 1):
		if a[z] != y:
			y = a[z]
			print(y, end=' ')
			continue
		y = b[z]
		print(y, end=' ')
	if a[n - 1] != y and a[n - 1] != a[0]:
		print(a[n - 1])
		continue
	if b[n - 1] != y and b[n - 1] != a[0]:
		print(b[n - 1])
		continue
	print(c[n - 1])


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	u = []
	for i in range(n):
		u.append([a[i]] + [b[i]] + [c[i]])
	p = []
	p.append(u[0][0])
	for i in range(1, len(u)):
		for k in u[i]:
			if k != p[-1]:
				p.append(k)
				break
	if p[-1] == p[0]:
		for i in u[-1]:
			if i != p[0] and i != p[-2]:
				p[-1] = i
				break
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	out = [a[0]] * n
	for i in range(1, n):
		if i != n - 1:
			if a[i] != out[i - 1]:
				out[i] = a[i]
			elif b[i] != out[i - 1]:
				out[i] = b[i]
			else:
				out[i] = c[i]
		elif a[i] != out[i - 1] and a[i] != out[0]:
			out[i] = a[i]
		elif b[i] != out[i - 1] and b[i] != out[0]:
			out[i] = b[i]
		else:
			out[i] = c[i]
	for i in out:
		print(i, end=' ')
	print()


import random
for _ in range(int(input())):
	n = int(input())
	fin = []
	for i in range(3):
		li = list(map(int, input().strip().split()))
		fin.append(li)
	fg = []
	fg.append(fin[0][0])
	for j in range(1, n):
		nos = [fin[0][j], fin[1][j], fin[2][j]]
		n = [i for i in nos if i != fg[j - 1]]
		fg.append(n[0])
	if fg[-1] == fg[0]:
		fuda = [fin[0][-1], fin[1][-1], fin[2][-1]]
		fg[-1] = [i for i in fuda if i != fg[0] and i != fg[-2]][0]
	for i in range(len(fg)):
		print(fg[i], end=' ')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for j in range(1, n):
		if j == n - 1:
			x = ans[0]
			y = ans[-1]
			if a[j] != x and a[j] != y:
				ans.append(a[j])
			elif b[j] != x and b[j] != y:
				ans.append(b[j])
			else:
				ans.append(c[j])
			break
		if a[j] != ans[-1]:
			ans.append(a[j])
		elif b[j] != ans[-1]:
			ans.append(b[j])
		else:
			ans.append(c[j])
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	c = [int(j) for j in input().split()]
	ans = [a[0]]
	for i in range(1, n):
		if a[i] != ans[(i - 1) % n]:
			x = a[i]
		elif b[i] != ans[(i - 1) % n]:
			x = b[i]
		else:
			x = c[i]
		ans.append(x)
	if ans[-1] == ans[0]:
		if a[n - 1] != ans[(n - 2) % n] and a[n - 1] != ans[0]:
			x = a[n - 1]
		elif b[n - 1] != ans[(n - 2) % n] and b[n - 1] != ans[0]:
			x = b[n - 1]
		else:
			x = c[n - 1]
		ans[n - 1] = x
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [-1] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		curr_list = [a[i], b[i], c[i]]
		for element in curr_list:
			if element != p[i - 1]:
				p[i] = element
				break
	curr_list = [a[n - 1], b[n - 1], c[n - 1]]
	for element in curr_list:
		if element != p[n - 2] and element != p[0]:
			p[n - 1] = element
			break
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	p = []
	for ind in range(n):
		if len(p) == 0:
			p.append(a[ind])
		elif len(p) == n - 1:
			if p[0] != a[ind] and p[ind - 1] != a[ind]:
				p.append(a[ind])
			elif p[0] != b[ind] and p[ind - 1] != b[ind]:
				p.append(b[ind])
			else:
				p.append(c[ind])
		elif p[ind - 1] != a[ind]:
			p.append(a[ind])
		elif p[ind - 1] != b[ind]:
			p.append(b[ind])
		else:
			p.append(c[ind])
	print(*p)


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(get_single_int()):
	n = get_single_int()
	a = get_list()
	b = get_list()
	c = get_list()
	ar = [a[0]]
	if a[0] == a[n - 1]:
		ar.append(b[n - 1])
	else:
		ar.append(a[n - 1])
	prev = ar[1]
	for j in range(n - 2, 0, -1):
		if a[j] != prev:
			ar.insert(1, a[j])
			prev = a[j]
			continue
		else:
			ar.insert(1, b[j])
			prev = b[j]
	if ar[0] == ar[1]:
		if a[1] != ar[0] and a[1] != ar[2]:
			ar[1] = a[1]
		elif b[1] != ar[0] and b[1] != ar[2]:
			ar[1] = b[1]
		elif c[1] != ar[0] and c[1] != ar[2]:
			ar[1] = c[1]
	print(*ar)


for _ in range(int(input())):
	(n, s) = (int(input()), [])
	a = [int(ai) for ai in input().split()]
	b = [int(bi) for bi in input().split()]
	c = [int(ci) for ci in input().split()]
	s.append(a[0])
	for i in range(1, n - 1):
		if s[i - 1] == a[i]:
			s.append(b[i])
		else:
			s.append(a[i])
	e = set([a[-1], b[-1], c[-1]])
	e -= set([s[0], s[-1]])
	print(*s, e.pop())


for _ in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	c = list(map(str, input().split()))
	l = a
	for i in range(1, len(a)):
		if l[i] == l[i - 1]:
			l[i] = b[i]
	if l[0] == l[n - 1] and b[n - 1] != l[n - 2] and (b[n - 1] != l[n - 1]):
		l[n - 1] = b[n - 1]
	elif l[0] == l[n - 1] and c[n - 1] != l[n - 2] and (c[n - 1] != l[n - 1]):
		a[n - 1] = c[n - 1]
	print(*l)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ANS = [-1] * n
	ANS[0] = A[0]
	for i in range(1, n - 1):
		if A[i] != ANS[i - 1]:
			ANS[i] = A[i]
		else:
			ANS[i] = B[i]
	if A[-1] != ANS[n - 2] and A[-1] != ANS[0]:
		ANS[-1] = A[-1]
	elif B[-1] != ANS[n - 2] and B[-1] != ANS[0]:
		ANS[-1] = B[-1]
	else:
		ANS[-1] = C[-1]
	print(*ANS)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		p = [a[0]]
		for i in range(1, n):
			if a[i] == p[-1]:
				p.append(b[i])
			else:
				p.append(a[i])
		if p[-1] == p[0] or p[-1] == p[-2]:
			p[-1] = c[-1]
		if p[-1] == p[0] or p[-1] == p[-2]:
			p[-1] = a[-1]
		if p[-1] == p[0] or p[-1] == p[-2]:
			p[-1] = b[-1]
		print(*p)
main()


for _ in range(int(input())):
	N = int(input())
	A = [int(i) for i in input().split(' ')]
	B = [int(i) for i in input().split(' ')]
	C = [int(i) for i in input().split(' ')]
	print(A[0], end=' ')
	prev = A[0]
	for i in range(1, N):
		if i == N - 1:
			if A[i] != prev and A[i] != A[0]:
				print(A[i], end=' ')
			elif B[i] != prev and B[i] != A[0]:
				print(B[i], end=' ')
			else:
				print(C[i], end=' ')
		elif A[i] != prev:
			prev = A[i]
			print(prev, end=' ')
		elif B[i] != prev:
			prev = B[i]
			print(prev, end=' ')
		else:
			prev = C[i]
			print(prev, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	third = list(map(int, input().split()))
	output = [first[0]]
	for i in range(1, n - 1):
		if output[i % n - 1] != first[i]:
			output.append(first[i])
		else:
			output.append(second[i])
	if first[n - 1] != output[-1] and first[n - 1] != output[0]:
		output.append(first[n - 1])
	elif second[n - 1] != output[-1] and second[n - 1] != output[0]:
		output.append(second[n - 1])
	else:
		output.append(third[n - 1])
	print(*output)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = [-1] * n
	ans[0] = a[0]
	ans[-1] = a[-1] if a[-1] != ans[0] else b[-1]
	for z in range(1, n - 2):
		if a[z] != ans[z - 1]:
			ans[z] = a[z]
		else:
			ans[z] = b[z]
	if a[-2] != ans[-1] and a[-2] != ans[-3]:
		ans[-2] = a[-2]
	elif b[-2] != ans[-1] and b[-2] != ans[-3]:
		ans[-2] = b[-2]
	else:
		ans[-2] = c[-2]
	print(*ans)


def listToString(s):
	str1 = ' '
	s1 = [str(x) for x in s]
	return str1.join(s1)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	pre = 0
	last = 0
	for i in range(n):
		if i == n - 1:
			last = p[0]
		if a[i] != pre and a[i] != last:
			p.append(a[i])
		elif b[i] != pre and b[i] != last:
			p.append(b[i])
		else:
			p.append(c[i])
		pre = p[i]
	print(listToString(p))


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
while n:
	n -= 1
	(m,) = I()
	a = I()
	b = I()
	c = I()
	t = [a[0]]
	for i in range(1, m - 1):
		if t[-1] != a[i]:
			t.append(a[i])
		else:
			t.append(b[i])
	for i in [a[-1], b[-1], c[-1]]:
		if i != t[-1] and i != a[0]:
			t.append(i)
			break
	print(*t)


import sys
import math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l3 = [int(x) for x in input().split()]
	a = [l1[0]]
	for i in range(1, n):
		if i == n - 1:
			if l1[i] != a[0] and l1[i] != a[-1]:
				a.append(l1[i])
			elif l2[i] != a[0] and l2[i] != a[-1]:
				a.append(l2[i])
			else:
				a.append(l3[i])
		elif l1[i] != a[-1]:
			a.append(l1[i])
		elif l2[i] != a[-1]:
			a.append(l2[i])
		else:
			a.append(l3[i])
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	o = []
	for i in range(n):
		if i == 0:
			o.append(a[i])
		else:
			l = []
			l.append(a[i])
			l.append(b[i])
			l.append(c[i])
			t = 0
			for j in range(3):
				if i == n - 1:
					if l[j] != o[i - 1] and t != 1 and (l[j] != o[0]):
						o.append(l[j])
						t = 1
				elif l[j] != o[i - 1] and t != 1:
					o.append(l[j])
					t = 1
	for i in range(n):
		print(o[i], end=' ')
	print()


game = int(input())
for i in range(game):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	ans.append(a[0])
	for j in range(1, n):
		if j == n - 1:
			if a[j] != ans[j - 1] and a[j] != ans[0]:
				ans.append(a[j])
			elif b[j] != ans[j - 1] and b[j] != ans[0]:
				ans.append(b[j])
			elif c[j] != ans[j - 1] and c[j] != ans[0]:
				ans.append(c[j])
		elif a[j] != ans[j - 1]:
			ans.append(a[j])
		elif b[j] != ans[j - 1]:
			ans.append(b[j])
		elif c[j] != ans[j - 1]:
			ans.append(c[j])
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	m = [list(map(int, input().split())) for i in range(3)]
	a = ['a']
	for i in range(n - 1):
		if a[-1] != m[0][i]:
			a.append(m[0][i])
			continue
		elif a[-1] != m[1][i]:
			a.append(m[1][i])
			continue
		else:
			a.append(m[2][i])
	if a[-1] != m[0][n - 1] and m[0][n - 1] != a[1]:
		a.append(m[0][n - 1])
	elif a[-1] != m[1][n - 1] and m[1][n - 1] != a[1]:
		a.append(m[1][n - 1])
	else:
		a.append(m[2][n - 1])
	print(*a[1:])


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().strip().split(' ')))
	B = list(map(int, input().strip().split(' ')))
	C = list(map(int, input().strip().split(' ')))
	p = [A[0]]
	i = 1
	while i < n - 1:
		while i < n - 1 and p[-1] != A[i]:
			p.append(A[i])
			i += 1
		while i < n - 1 and p[-1] != B[i]:
			p.append(B[i])
			i += 1
		while i < n - 1 and p[-1] != C[i]:
			p.append(C[i])
			i += 1
	if A[n - 1] != p[n - 2] and A[n - 1] != p[0]:
		p.append(A[n - 1])
	elif B[n - 1] != p[n - 2] and B[n - 1] != p[0]:
		p.append(B[n - 1])
	else:
		p.append(C[n - 1])
	for i in p:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = [A[0]]
	for i in range(1, n - 1):
		if A[i] != ans[-1]:
			ans.append(A[i])
		elif B[i] != ans[-1]:
			ans.append(B[i])
		elif C[i] != ans[-1]:
			ans.append(C[i])
	if A[n - 1] != ans[-1] and A[n - 1] != ans[0]:
		ans.append(A[n - 1])
	elif B[n - 1] != ans[-1] and B[n - 1] != ans[0]:
		ans.append(B[n - 1])
	elif C[n - 1] != ans[-1] and C[n - 1] != ans[0]:
		ans.append(C[n - 1])
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = tuple(input().split())
	b = tuple(input().split())
	c = tuple(input().split())
	print(a[0], end=' ')
	last = a[0]
	for i in range(1, n):
		if i % (n - 1) == 0:
			if a[0] != a[i] and last != a[i]:
				print(a[i], end=' ')
				last = a[i]
			elif a[0] != b[i] and last != b[i]:
				print(b[i], end=' ')
				last = b[i]
			elif a[0] != c[i] and last != c[i]:
				print(c[i], end=' ')
				last = c[i]
		elif a[i] != last:
			print(a[i], end=' ')
			last = a[i]
		else:
			print(b[i], end=' ')
			last = b[i]
	print()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().strip().split()))
	b = list(map(int, stdin.readline().strip().split()))
	c = list(map(int, stdin.readline().strip().split()))
	l = []
	for i in range(n):
		if i == 0:
			l.append(a[i])
		elif i == n - 1:
			if a[i] != l[i - 1] and l[0] != a[i]:
				l.append(a[i])
			elif b[i] != l[i - 1] and l[0] != b[i]:
				l.append(b[i])
			else:
				l.append(c[i])
		elif a[i] != l[i - 1]:
			l.append(a[i])
		elif b[i] != l[i - 1]:
			l.append(b[i])
		else:
			l.append(c[i])
	print(*l)


case = int(input())
for i in range(case):
	number = int(input())
	a = [int(v) for v in input().split()]
	b = [int(u) for u in input().split()]
	c = [int(w) for w in input().split()]
	for j in range(1, number):
		if a[j] == a[j - 1]:
			a[j] = b[j]
	if a[number - 1] == a[0]:
		a[number - 1] = c[number - 1]
	if a[number - 1] == a[number - 2]:
		a[number - 1] = b[number - 1]
	ans = ''
	for k in range(len(a)):
		ans += str(a[k]) + ' '
	print(ans.rstrip(' '))


t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	answer = [a[0]]
	for i in range(n - 2):
		if answer[i] != a[i + 1]:
			answer.append(a[i + 1])
		elif answer[i] != b[i + 1]:
			answer.append(b[i + 1])
		else:
			answer.append(c[i + 1])
	if a[0] != a[-1] and answer[-1] != a[-1]:
		answer.append(a[-1])
	elif a[0] != b[-1] and answer[-1] != b[-1]:
		answer.append(b[-1])
	else:
		answer.append(c[-1])
	answers.append(answer)
for j in range(t):
	print(' '.join(answers[j]))


for i in range(int(input())):
	n = int(input())
	ans = []
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	arr3 = [int(i) for i in input().split()]
	zip1 = zip(arr1, arr2, arr3)
	list1 = [sorted(i) for i in zip1]
	ans = []
	c = 0
	index = 1
	for i in list1:
		if ans == []:
			ans.append(i[0])
			c += 1
		else:
			index += 1
			if i[0] != ans[-1] and i[0] != ans[(n + 1) % index - 1]:
				ans.append(i[0])
			elif i[2] != ans[-1] and i[2] != ans[(n + 1) % index - 1]:
				ans.append(i[2])
			else:
				ans.append(i[1])
	print(*ans, sep=' ')


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict
import os
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 solve(arr, brr, crr):
	console('----- solving ------')
	res = [arr[0]]
	for (a, b, c) in zip(arr[1:], brr[1:], crr[1:]):
		if a != res[-1]:
			res.append(a)
		elif b != res[-1]:
			res.append(b)
		else:
			res.append(c)
	if res[0] == res[-1]:
		if a != res[-2] and a != res[0]:
			res[-1] = a
		elif b != res[-2] and b != res[0]:
			res[-1] = b
		else:
			res[-1] = c
	return res

def console(*args):
	return
for case_num in range(int(input())):
	k = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(map(int, input().split()))
	res = solve(arr, brr, crr)
	print(' '.join((str(x) for x in res)))


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	li = []
	for i in range(0, n):
		x = [a[i], b[i], c[i]]
		li.append(x)
	p = [a[0]]
	for i in range(1, n):
		for j in li[i]:
			if j != p[i - 1]:
				p.append(j)
				break
	if p[0] == p[n - 1]:
		for i in li[n - 1]:
			if i != p[0] and i != p[n - 2]:
				p[n - 1] = i
	p = ' '.join(p)
	print(p)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = [float('inf') for x in range(n)]
	ans[0] = A[0]
	for i in range(1, len(A) - 1):
		if ans[i - 1] != A[i]:
			ans[i] = A[i]
		elif ans[i - 1] != B[i]:
			ans[i] = B[i]
		else:
			ans[i] = C[i]
	if A[n - 1] != ans[n - 2] and A[n - 1] != ans[0]:
		ans[n - 1] = A[n - 1]
	elif B[n - 1] != ans[n - 2] and B[n - 1] != ans[0]:
		ans[n - 1] = B[n - 1]
	else:
		ans[n - 1] = C[n - 1]
	for x in ans:
		print(x, end=' ')
	print()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

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

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

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

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	b = lis()
	c = lis()
	aa = []
	for i in range(n):
		aa.append((a[i], b[i], c[i]))
	ind = 0
	ans = [0] * n
	ans[n - 1] = a[n - 1]
	for i in range(n - 1):
		for j in range(3):
			if ans[i - 1] == aa[i][j]:
				continue
			ans[ind] = aa[i][j]
			ind += 1
			break
	for j in range(3):
		if aa[n - 1][j] == ans[0] or aa[n - 1][j] == ans[n - 2]:
			continue
		ans[n - 1] = aa[n - 1][j]
		break
	print(' '.join((str(ans[i]) for i in range(len(ans)))))
testcase(int(inp()))


test = int(input())
for i in range(test):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	c = [int(x) for x in input().split(' ')]
	p = [a[0]]
	for i in range(1, n - 1):
		z = [a[i], b[i], c[i]]
		for j in z:
			if j != p[i - 1]:
				p.append(j)
				break
	i = -1
	z = [a[i], b[i], c[i]]
	for j in z:
		if j != p[-1] and j != a[0]:
			p.append(j)
			break
	print(*p)


for _ in range(int(input())):
	k = [0]
	a = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	d = [int(x) for x in input().split()]
	i = 0
	for i in range(a):
		if i != a - 1:
			for j in [b[i], c[i], d[i]]:
				if j != k[-1]:
					k.append(j)
					break
		else:
			for j in [b[i], c[i], d[i]]:
				if j != k[-1] and j != k[1]:
					k.append(j)
					break
	k.pop(0)
	print(*k)


import sys
import math
xc = 21398712897318923679187263
for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = max(a[0], b[0], c[0])
	for i in range(1, n):
		x = max(a[i], b[i], c[i])
		if i == n - 1:
			if a[i] != ans[i - 1] and a[i] != ans[0]:
				ans[i] = a[i]
			elif b[i] != ans[i - 1] and b[i] != ans[0]:
				ans[i] = b[i]
			else:
				ans[i] = c[i]
		elif x == ans[i - 1]:
			x = min(a[i], b[i], c[i])
			ans[i] = x
		else:
			ans[i] = x
	print(*ans)


t = int(input())

def solve():
	v = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	sol = []
	for i in range(v):
		if sol == []:
			sol += [a[i]]
			continue
		if i == v - 1:
			if a[i] != sol[-1] and sol[0] != a[i]:
				sol += [a[i]]
			elif b[i] != sol[-1] and sol[0] != b[i]:
				sol += [b[i]]
			elif c[i] != sol[-1] and sol[0] != c[i]:
				sol += [c[i]]
		elif a[i] != sol[-1]:
			sol += [a[i]]
		elif b[i] != sol[-1]:
			sol += [c[i]]
		elif c[i] != sol[-1]:
			sol += [c[i]]
	print(*sol)
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	res = [A[0]]
	for i in range(1, n - 1):
		for sb in [A[i], B[i], C[i]]:
			if sb != res[-1]:
				res.append(sb)
				break
	for sb in [A[n - 1], B[n - 1], C[n - 1]]:
		if sb != res[0] and sb != res[-1]:
			res.append(sb)
			break
	print(*res)


T = int(input())
for I in range(0, T):
	N = int(input())
	A = [input().split(' '), input().split(' '), input().split(' ')]
	Z = '0'
	X = []
	for J in range(0, len(A[0])):
		if J == 0:
			Z = A[0][0]
			X.append(Z)
		elif J == len(A[0]) - 1:
			F = [A[0][J], A[1][J], A[2][J]]
			if Z in F:
				F.remove(Z)
			if X[0] in F:
				F.remove(X[0])
			Z = F[0]
			X.append(Z)
		else:
			F = [A[0][J], A[1][J], A[2][J]]
			if Z in F:
				F.remove(Z)
			Z = F[0]
			X.append(Z)
	print(' '.join(X))


def main(n, a, b, c):
	res = [a[0]]
	for i in range(1, n - 1):
		if a[i] == res[-1]:
			res.append(b[i])
		else:
			res.append(a[i])
	if a[n - 1] not in [res[-1], res[0]]:
		res.append(a[n - 1])
		return res
	if b[n - 1] not in [res[-1], res[0]]:
		res.append(b[n - 1])
		return res
	res.append(c[n - 1])
	return res
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(*main(n, a, b, c))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	cnt = 0
	l = []
	for i in range(n):
		if i == 0:
			l.append(a[i])
			continue
		if l[-1] == a[i]:
			l.append(b[i])
		else:
			l.append(a[i])
	l[-1] = a[-1]
	if l[-1] != l[-2] and l[-1] != l[0]:
		print(*l)
		continue
	l[-1] = b[-1]
	if l[-1] != l[-2] and l[-1] != l[0]:
		print(*l)
		continue
	l[-1] = c[-1]
	if l[-1] != l[-2] and l[-1] != l[0]:
		print(*l)
		continue


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	for i in range(1, n - 1):
		if A[i] == A[i - 1]:
			A[i] = B[i]
	A[-1] = ({A[-1], B[-1], C[-1]} - {A[-2], A[0]}).pop()
	print(*A)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	A = list(map(int, sys.stdin.readline().strip().split()))
	B = list(map(int, sys.stdin.readline().strip().split()))
	C = list(map(int, sys.stdin.readline().strip().split()))
	P = [A[0]]
	for i in range(1, n):
		if A[i] != P[0] and A[i] != P[-1]:
			P.append(A[i])
		elif B[i] != P[0] and B[i] != P[-1]:
			P.append(B[i])
		elif C[i] != P[0] and C[i] != P[-1]:
			P.append(C[i])
	print(' '.join(list(map(str, P))))


for _ in range(int(input())):
	n = int(input())
	ans = []
	for i in range(n):
		ans.append(0)
	firstArray = [int(inputNum) for inputNum in input().split()]
	secondArray = [int(inputNum) for inputNum in input().split()]
	thirdArray = [int(inputNum) for inputNum in input().split()]
	ans[0] = firstArray[0]
	for i in range(n):
		if i < n - 1:
			if firstArray[i] != ans[i - 1]:
				ans[i] = firstArray[i]
			elif secondArray[i] != ans[i - 1]:
				ans[i] = secondArray[i]
			elif thirdArray[i] != ans[i - 1]:
				ans[i] = thirdArray[i]
		elif firstArray[i] != ans[i - 1] and firstArray[i] != ans[0]:
			ans[i] = firstArray[i]
		elif secondArray[i] != ans[i - 1] and secondArray[i] != ans[0]:
			ans[i] = secondArray[i]
		elif thirdArray[i] != ans[i - 1] and thirdArray[i] != ans[0]:
			ans[i] = thirdArray[i]
	for res in ans:
		print(res, end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if n == 1:
		print(a[0])
	else:
		p = [0 for i in range(n)]
		p[0] = a[0]
		for i in range(1, n - 1):
			if a[i] != p[i - 1]:
				p[i] = a[i]
			else:
				p[i] = b[i]
		last = set([p[-2], p[0]])
		if a[-1] not in last:
			p[-1] = a[-1]
		elif b[-1] not in last:
			p[-1] = b[-1]
		else:
			p[-1] = c[-1]
		print(*p)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [0] * n
	m = 0
	while m != n:
		if m == 0:
			p[m] = a[m]
		elif m == n - 1:
			if p[m - 1] != a[m] and p[0] != a[m]:
				p[m] = a[m]
			elif p[m - 1] != b[m] and p[0] != b[m]:
				p[m] = b[m]
			else:
				p[m] = c[m]
		elif a[m] == p[m - 1]:
			p[m] = b[m]
		elif b[m] == p[m - 1]:
			p[m] = c[m]
		else:
			p[m] = a[m]
		m += 1
	print(*p)


def do():
	n = int(input())
	data = list(map(int, input().split()))
	datb = list(map(int, input().split()))
	datc = list(map(int, input().split()))
	res = []
	p = -10
	for i in range(n - 1):
		if data[i] != p:
			p = data[i]
			res.append(p)
		else:
			p = datb[i]
			res.append(p)
	d = []
	d.append(res[0])
	d.append(res[-1])
	if data[n - 1] not in d:
		res.append(data[n - 1])
	elif datb[n - 1] not in d:
		res.append(datb[n - 1])
	elif datc[n - 1] not in d:
		res.append(datc[n - 1])
	print(' '.join(list(map(str, res))))
q = int(input())
for _ in range(q):
	do()


for _ in range(int(input())):
	n = int(input())
	X = [int(_) for _ in input().split()]
	Y = [int(_) for _ in input().split()]
	Z = [int(_) for _ in input().split()]
	A = [X[0]]
	for _ in range(1, n - 1):
		if X[_] != A[-1]:
			A.append(X[_])
		elif Y[_] != A[-1]:
			A.append(Y[_])
		else:
			A.append(Z[_])
	if X[n - 1] != A[-1] and X[n - 1] != A[0]:
		A.append(X[n - 1])
	elif Y[n - 1] != A[-1] and Y[n - 1] != A[0]:
		A.append(Y[n - 1])
	else:
		A.append(Z[n - 1])
	print(*A)


import math
t = int(input())
for w in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	l = [a[0]]
	prev = a[0]
	for i in range(1, n - 1):
		if a[i] == prev:
			l.append(b[i])
			prev = b[i]
		else:
			l.append(a[i])
			prev = a[i]
	if a[-1] != prev and a[-1] != l[0]:
		l.append(a[-1])
	elif b[-1] != prev and b[-1] != l[0]:
		l.append(b[-1])
	else:
		l.append(c[-1])
	print(*l)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(v) for v in input().split()]
	b = [int(v) for v in input().split()]
	c = [int(v) for v in input().split()]
	for i in range(1, n - 1):
		if a[i] != a[i - 1]:
			continue
		elif b[i] != a[i - 1]:
			a[i] = b[i]
	ch = [a[n - 2], a[0]]
	if a[n - 1] not in ch:
		pass
	elif b[n - 1] not in ch:
		a[n - 1] = b[n - 1]
	else:
		a[n - 1] = c[n - 1]
	print(' '.join([str(x) for x in a]))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	pre = -1
	n = int(input())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	cr = list(map(int, input().split()))
	ans = []
	for i in range(n):
		if i != n - 1:
			if ar[i] != pre:
				ans.append(ar[i])
				pre = ar[i]
			elif br[i] != pre:
				ans.append(br[i])
				pre = br[i]
			else:
				ans.append(cr[i])
				pre = cr[i]
		elif ar[i] != pre and ar[i] != ans[0]:
			ans.append(ar[i])
		elif br[i] != pre and br[i] != ans[0]:
			ans.append(br[i])
		elif cr[i] != pre and cr[i] != ans[0]:
			ans.append(cr[i])
	print(*ans)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for i in range(1, n):
		if a[i] == p[-1]:
			if b[i] == p[-1]:
				p.append(c[i])
			else:
				p.append(b[i])
		else:
			p.append(a[i])
	if p[-1] == p[0]:
		if a[-1] != p[0] and a[-1] != p[-2]:
			p[-1] = a[-1]
		elif b[-1] != p[0] and b[-1] != p[-2]:
			p[-1] = b[-1]
		else:
			p[-1] = c[-1]
	print(*p)
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


import sys

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	for i in range(1, len(q), 4):
		n = q[i][0]
		a = q[i + 1]
		b = q[i + 2]
		c = q[i + 3]
		ret = [a[0]]
		for i in range(1, len(a)):
			if i == len(a) - 1:
				if a[i] != ret[i - 1] and a[i] != ret[0]:
					ret.append(a[i])
				elif b[i] != ret[i - 1] and b[i] != ret[0]:
					ret.append(b[i])
				else:
					ret.append(c[i])
			elif a[i] != ret[i - 1]:
				ret.append(a[i])
			elif b[i] != ret[i - 1]:
				ret.append(b[i])
			else:
				ret.append(c[i])
		print(' '.join([str(j) for j in ret]))
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	arr = []
	count = 0
	for (aa, bb, cc) in zip(a, b, c):
		if count != aa:
			arr.append(aa)
			count = aa
		elif count != bb:
			arr.append(bb)
			count = bb
		else:
			arr.append(cc)
			count = cc
	if arr[0] == arr[-1]:
		if a[-1] != arr[0] and a[-1] != arr[-2]:
			arr.insert(n, a[-1])
		elif b[-1] != arr[0] and b[-1] != arr[-2]:
			arr.insert(n, b[-1])
		else:
			arr.insert(n, c[-1])
		arr.pop(-2)
	print(*arr)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	j = 0
	ans.append(a[0])
	for i in range(1, n - 1):
		if ans[-1] != a[i]:
			ans.append(a[i])
			continue
		if ans[-1] != b[i]:
			ans.append(b[i])
			continue
		if ans[-1] != c[i]:
			ans.append(c[i])
			continue
	flag = False
	if ans[0] != a[n - 1] and ans[-1] != a[n - 1]:
		flag = True
		ans.append(a[n - 1])
	if not flag and ans[-1] != b[n - 1] and (ans[0] != b[n - 1]):
		flag = True
		ans.append(b[n - 1])
	if not flag and ans[-1] != c[n - 1] and (ans[0] != c[n - 1]):
		ans.append(c[n - 1])
	print(*ans)


import sys, math, cmath, time, collections
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	b = inlt()
	c = inlt()
	q = [a[0]]
	for i in range(1, len(a)):
		if a[i] == q[-1]:
			q.append(b[i])
		else:
			q.append(a[i])
	if len(a) >= 2 and q[-1] == q[0]:
		if q[0] != a[-1] and q[-2] != a[-1]:
			q[-1] = a[-1]
		elif q[0] != b[-1] and q[-2] != b[-1]:
			q[-1] = b[-1]
		else:
			q[-1] = c[-1]
	print(*q)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

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

def insr():
	return input().strip()

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

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def ceil(a, b):
	return -(-a // b)
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(2 * n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	n = inn()
	a = [arr() for x in range(3)]
	ans = []
	last = inf
	for i in range(n):
		if i == n - 1:
			for j in range(3):
				if a[j][i] != ans[0] and a[j][i] != last:
					ans += [a[j][i]]
					break
		else:
			for j in range(3):
				if a[j][i] != last:
					ans += [a[j][i]]
					last = a[j][i]
					break
	print(*ans)


t = int(input())
for test in range(t):
	n = int(input())
	l = []
	for i in range(3):
		arr = list(map(int, input().split()))
		l.append(arr)
	f = l[0][0]
	new = []
	new.append(f)
	for i in range(1, n - 1):
		t = []
		for j in range(3):
			t.append(l[j][i])
		new.append((set(t) - {new[i - 1]}).pop())
	t = []
	for j in range(3):
		t.append(l[j][n - 1])
	new.append((set(t) - {new[n - 2], new[0]}).pop())
	for i in range(n):
		print(new[i], end=' ')
	print()


def sm(a, b, x, y, n):
	temp = a - x
	temp1 = min(temp, n)
	a = a - temp1
	n = n - temp1
	b = b - n
	return a * b
q = int(input())
for d in range(q):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	ans = []
	ans.append(a[0])
	for i in range(1, n):
		if a[i] != ans[i - 1]:
			ans.append(a[i])
		elif b[i] != ans[i - 1]:
			ans.append(b[i])
		elif c[i] != ans[i - 1]:
			ans.append(c[i - 1])
	temp1 = a[n - 1]
	temp2 = b[n - 1]
	temp3 = c[n - 1]
	if temp1 != ans[0] and temp1 != ans[n - 2]:
		ans[n - 1] = temp1
	elif temp2 != ans[0] and temp2 != ans[n - 2]:
		ans[n - 1] = temp2
	elif temp3 != ans[0] and temp3 != ans[n - 2]:
		ans[n - 1] = temp3
	for i in range(len(ans)):
		print(ans[i])


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != p[-1]:
				p.append(a[i])
			elif b[i] != p[-1]:
				p.append(b[i])
			else:
				p.append(c[i])
		elif a[i] != p[0] and a[i] != p[-1]:
			p.append(a[i])
		elif b[i] != p[0] and b[i] != p[-1]:
			p.append(b[i])
		else:
			p.append(c[i])
	print(*p)


for z in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n):
		f = 0
		if i != n - 1:
			if p[i - 1] != a[i]:
				p += [a[i]]
				f = 1
			elif p[i - 1] != b[i] and f == 0:
				p += [b[i]]
				f = 1
			elif p[i - 1] != c[i] and f == 0:
				p += [c[i]]
				f = 1
		elif p[0] != a[i] and p[i - 1] != a[i]:
			p += [a[i]]
		elif p[0] != b[i] and p[i - 1] != b[i]:
			p += [b[i]]
		elif p[0] != c[i] and p[i - 1] != c[i]:
			p += [c[i]]
	print(*p)


import sys
input = sys.stdin.readline

def solve(a, b, c, n):
	res = [0] * n
	res[0] = a[0]
	for i in range(1, len(a) - 1):
		if a[i] != res[i - 1]:
			res[i] = a[i]
		else:
			res[i] = b[i]
	if a[-1] != res[0] and a[-1] != res[-2]:
		res[-1] = a[-1]
	elif b[-1] != res[0] and b[-1] != res[-2]:
		res[-1] = b[-1]
	else:
		res[-1] = c[-1]
	return res
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(*solve(a, b, c, n))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	lst = [a[0]]
	for i in range(1, n):
		if i != n - 1:
			if lst[i - 1] == a[i]:
				if lst[i - 1] == b[i]:
					lst.append(c[i])
				else:
					lst.append(b[i])
			else:
				lst.append(a[i])
		elif lst[i - 1] == a[i] or lst[0] == a[i]:
			if lst[i - 1] == b[i] or lst[0] == b[i]:
				lst.append(c[i])
			else:
				lst.append(b[i])
		else:
			lst.append(a[i])
	print(*lst)


from sys import stdin, stdout
from collections import defaultdict as dd
from math import sqrt, log
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n):
		if b[i] != p[-1]:
			p.append(b[i])
		else:
			p.append(c[i])
	if p[0] == p[-1]:
		if b[0] != p[1]:
			p[0] = b[0]
		else:
			p[0] = c[0]
	print(*p)


t = int(input())
for test_cases in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	c = [int(i) for i in input().split(' ')]
	prev = a[0]
	final_str = str(prev) + ' '
	for i in range(1, n - 1):
		cnt = 0
		if a[i] != prev:
			final_str += str(a[i]) + ' '
			prev = a[i]
			cnt += 1
		if b[i] != prev and cnt == 0:
			final_str += str(b[i]) + ' '
			prev = b[i]
			cnt += 1
		if c[i] != prev and cnt == 0:
			final_str += str(c[i]) + ' '
			prev = c[i]
			cnt += 1
	y = [a[-1], b[-1], c[-1]]
	ls = [a[0], prev]
	for i in y:
		if i not in ls:
			final_str += str(i)
			break
	print(final_str)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p += [a[i]]
		elif b[i] != p[i - 1]:
			p += [b[i]]
		else:
			p += [c[i]]
	if a[n - 1] != p[n - 2] and a[n - 1] != p[0]:
		p += [a[n - 1]]
	elif b[n - 1] != p[n - 2] and b[n - 1] != p[0]:
		p += [b[n - 1]]
	else:
		p += [c[n - 1]]
	s = str(p[0])
	for k in range(1, n):
		s += ' ' + str(p[k])
	print(s)


t = int(input())
for p in range(t):
	n = int(input())
	array_a = list(map(int, input().split()))
	array_b = list(map(int, input().split()))
	array_c = list(map(int, input().split()))
	print_array = [array_a[0]]
	for i in range(1, n):
		if i != n - 1:
			if array_a[i] != print_array[i - 1]:
				print_array.append(array_a[i])
			else:
				print_array.append(array_b[i])
		elif array_a[i] != print_array[i - 1] and print_array[0] != array_a[i]:
			print_array.append(array_a[i])
		elif array_b[i] != print_array[i - 1] and print_array[0] != array_b[i]:
			print_array.append(array_b[i])
		else:
			print_array.append(array_c[i])
	for i in print_array:
		print(i, end=' ')
	print('')


n = int(input())
while n:
	s = int(input())
	s1 = input().split(' ')
	i1 = [int(v) for v in s1]
	s2 = input().split(' ')
	i2 = [int(v) for v in s2]
	s3 = input().split(' ')
	i3 = [int(v) for v in s3]
	pi = []
	curr_index = 0
	for (iv1, iv2, iv3) in zip(i1, i2, i3):
		if not pi:
			pi = [iv1]
		else:
			for x in [iv1, iv2, iv3]:
				if x != pi[-1]:
					if curr_index == s - 1 and x == pi[0]:
						continue
					else:
						pi += [x]
						break
		curr_index += 1
	print(' '.join([str(v) for v in pi]))
	n -= 1


def solution():
	n = int(input())
	ans = []
	a = input().split()
	b = input().split()
	c = input().split()
	for i in range(n):
		if i == 0:
			ans.append(a[i])
		else:
			ans.append(a[i])
			if ans[i] == ans[i - 1]:
				ans[i] = b[i]
			if i == n - 1 and ans[i] == ans[0]:
				ans[i] = c[i]
			if i == n - 1 and ans[i] == ans[i - 1]:
				ans[i] = b[i]
	print(' '.join(ans))
t = int(input())
for _ in range(t):
	solution()


t = int(input())

def check_end(arr, i, d):
	if arr[i] == arr[0] or arr[i] == arr[i - 1]:
		k = 0
		while arr[i] == arr[0] or arr[i] == arr[i - 1]:
			if k == 3:
				break
			arr[i] = d[i][k]
			k += 1
	return arr[i]

def check_begin(arr, i, d):
	if arr[i] == arr[len(arr) - 1] or arr[i] == arr[i + 1]:
		k = 0
		while arr[i] == arr[len(arr) - 1] or arr[i] == arr[i + 1]:
			if k == 3:
				break
			arr[i] = d[i][k]
			k += 1
	return arr[i]

def check(arr, i, d):
	if arr[i] == arr[i - 1] or arr[i] == arr[i + 1]:
		k = 0
		while arr[i] == arr[i - 1] or arr[i] == arr[i + 1]:
			if k == 3:
				break
			arr[i] = d[i][k]
			k += 1
	return arr[i]
for i in range(t):
	n = int(input())
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	c = [int(_) for _ in input().split()]
	d = {}
	arr = a
	for i in range(n):
		d[i] = [a[i], b[i], c[i]]
	for i in range(len(arr)):
		if i == 0:
			arr[i] = check_begin(arr, i, d)
		elif i == len(arr) - 1:
			arr[i] = check_end(arr, i, d)
		else:
			arr[i] = check(arr, i, d)
	s = ''
	for i in arr:
		s = s + str(i) + ' '
	print(s[:-1])


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	ans = []
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans.append(str(a[0]))
	for i in range(1, n - 1):
		if ans[-1] == str(a[i]):
			ans.append(str(b[i]))
		else:
			ans.append(str(a[i]))
	if ans[0] != str(a[n - 1]) and ans[-1] != str(a[n - 1]):
		ans.append(str(a[n - 1]))
	elif ans[0] != str(b[n - 1]) and ans[-1] != str(b[n - 1]):
		ans.append(str(b[n - 1]))
	else:
		ans.append(str(c[n - 1]))
	print(' '.join(ans))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	an = []
	for i in range(n):
		if i == 0:
			an.append(a[i])
		elif i == n - 1:
			k = [a[i], b[i], c[i]]
			try:
				k.remove(a[0])
			except:
				pass
			try:
				k.remove(an[len(an) - 1])
			except:
				pass
			an.append(k[0])
		else:
			k = [a[i], b[i], c[i]]
			if k[0] == an[len(an) - 1]:
				an.append(k[1])
			else:
				an.append(k[0])
	print(*an)


for _ in range(int(input())):
	n = int(input())
	(a, b, c) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
	pre = None
	r = []
	for i in range(n - 1):
		p = [a[i], b[i], c[i]]
		q = [a[i + 1], b[i + 1], c[i + 1]]
		for u in p:
			kitti = False
			if pre != None and u == pre:
				continue
			for v in q:
				if u != v:
					r.append(u)
					pre = u
					kitti = True
					break
			if kitti:
				break
	i = n - 1
	p = [a[i], b[i], c[i]]
	for i in p:
		if i != pre and i != r[0]:
			r.append(i)
			break
	print(*r)


for i1 in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	ans = a
	for i in range(1, n):
		if ans[i] == ans[i - 1]:
			ans[i] = b[i]
	if ans[-1] == ans[0]:
		ans[-1] = c[-1]
	if ans[-1] == ans[-2]:
		ans[-1] = b[-1]
	print(*ans)


def r(i, s):
	global a, b, c, n, f
	if i == n:
		print(*s[1:])
		f = 1
	if n - 1 == i:
		if f == 0 and a[i] != s[-1] and (a[i] != s[1]):
			r(i + 1, s + [a[i]])
		elif f == 0 and b[i] != s[-1] and (b[i] != s[1]):
			r(i + 1, s + [b[i]])
		elif f == 0 and c[i] != s[-1] and (c[i] != s[1]):
			r(i + 1, s + [c[i]])
	elif f == 0 and a[i] != s[-1]:
		r(i + 1, s + [a[i]])
	elif f == 0 and b[i] != s[-1]:
		r(i + 1, s + [b[i]])
	elif f == 0 and c[i] != s[-1]:
		r(i + 1, s + [c[i]])
for _ in range(int(input())):
	f = 0
	n = int(input())
	(a, b, c) = ([int(x) for x in input().split()], [int(x) for x in input().split()], [int(x) for x in input().split()])
	r(0, [-1])


import collections
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	deq_mat = collections.deque([])
	deq_result = collections.deque([])
	deq_mat.append(a)
	deq_mat.append(b)
	deq_mat.append(c)
	deq_result.append(deq_mat[0][0])
	for j in range(1, n):
		for k in range(3):
			if deq_mat[k][j] != deq_result[-1]:
				if j == n - 1:
					if deq_mat[k][j] != deq_result[0]:
						deq_result.append(deq_mat[k][j])
						break
				else:
					deq_result.append(deq_mat[k][j])
					break
	print(*deq_result)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

def li():
	return [int(i) for i in input().split()]

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = li()
		c = li()
		p = [a[0]]
		for i in range(1, n - 1, 1):
			if p[i - 1] != a[i]:
				p.append(a[i])
				continue
			elif p[i - 1] != b[i]:
				p.append(b[i])
				continue
			else:
				p.append(c[i])
		if p[n - 2] != a[n - 1] and p[0] != a[n - 1]:
			p.append(a[n - 1])
		elif p[n - 2] != b[n - 1] and p[0] != b[n - 1]:
			p.append(b[n - 1])
		else:
			p.append(c[n - 1])
		print(*p)
main()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	res = [0] * n
	res[0] = a[0]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != res[0] and a[i] != res[i - 1]:
				res[i] = a[i]
			elif b[i] != res[0] and b[i] != res[i - 1]:
				res[i] = b[i]
			else:
				res[i] = c[i]
		elif a[i] != res[i - 1]:
			res[i] = a[i]
		elif b[i] != res[i - 1]:
			res[i] = b[i]
		else:
			res[i] = c[i]
	print(*res)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = a
	for x in range(1, n - 1):
		if p[x] == p[x - 1]:
			p[x] = b[x]
	if p[n - 1] == p[n - 2] or p[n - 1] == p[0]:
		p[n - 1] = b[n - 1]
	if p[n - 1] == p[n - 2] or p[n - 1] == p[0]:
		p[n - 1] = c[n - 1]
	for x in range(n):
		print(p[x], end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = [a[0]]
	pre = a[0]
	for i in range(1, n - 1):
		if a[i] != pre:
			ans.append(a[i])
			pre = a[i]
			continue
		elif b[i] != pre:
			ans.append(b[i])
			pre = b[i]
			continue
		else:
			ans.append(c[i])
			pre = c[i]
	temp = (ans[-1], ans[0])
	if a[-1] not in temp:
		ans.append(a[-1])
	elif b[-1] not in temp:
		ans.append(b[-1])
	else:
		ans.append(c[-1])
	print(*ans)
	t -= 1


a = int(input())
for k in range(0, a):
	n = int(input())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	i = 1
	p = [b[0]]
	print(b[0], end=' ')
	while i < n:
		if len(p) < n - 1:
			if p[len(p) - 1] != b[i]:
				p.append(b[i])
				print(b[i], end=' ')
			elif p[len(p) - 1] != c[i]:
				p.append(c[i])
				print(c[i], end=' ')
			elif p[len(p) - 1] != d[i]:
				p.append(d[i])
				print(d[i], end=' ')
		elif len(p) == n - 1:
			if p[len(p) - 1] != b[i] and p[0] != b[i]:
				p.append(b[i])
				print(b[i], end=' ')
			elif p[len(p) - 1] != c[i] and p[0] != c[i]:
				p.append(c[i])
				print(c[i], end=' ')
			elif p[len(p) - 1] != d[i] and p[0] != d[i]:
				p.append(d[i])
				print(d[i], end=' ')
		else:
			break
		i = i + 1
	print('\n')


from functools import lru_cache
T = int(input())
for _ in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, N):
		s = {ans[-1], ans[0]}
		if a[i] not in s:
			ans.append(a[i])
		elif b[i] not in s:
			ans.append(b[i])
		else:
			ans.append(c[i])
	print(' '.join(map(str, ans)))


T = int(input())
for t in range(T):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	A = []
	for i in range(n):
		A.append((a[i], b[i], c[i]))
	ans = [a[0]]
	for i in range(1, n - 1):
		for j in range(3):
			if A[i][j] != ans[-1]:
				ans.append(A[i][j])
				break
	for j in range(3):
		if A[-1][j] != ans[-1] and A[-1][j] != ans[0]:
			ans.append(A[-1][j])
			break
	print(*ans)


for _ in ' ' * int(input()):
	a = int(input())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	k = [0] * a
	k[0] = b[0]
	for i in range(1, a):
		if k[i - 1] != b[i]:
			k[i] = b[i]
		elif k[i - 1] != c[i]:
			k[i] = c[i]
		else:
			k[i] = d[i]
	if k[-1] == k[0]:
		if c[0] != k[1]:
			k[0] = c[0]
		else:
			k[0] = d[0]
	print(*k)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [-1]
	for i in range(n):
		if i < n - 1:
			for num in [a[i], b[i], c[i]]:
				if ans[-1] != num:
					ans.append(num)
					break
		else:
			for num in [a[i], b[i], c[i]]:
				if ans[-1] != num and ans[1] != num:
					ans.append(num)
					break
	print(*ans[1:])


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	v1 = min(A[0], B[0], C[0])
	ans = [v1]
	ls = -1
	for a in range(1, n):
		if a % 2 == 1:
			v = max(A[a], B[a], C[a])
		else:
			v = min(A[a], B[a], C[a])
		if v == ans[-1]:
			if a % 2 == 1:
				v = min(A[a], B[a], C[a])
			else:
				v = max(A[a], B[a], C[a])
		ans.append(v)
	s = 0
	while ans[-1] == ans[0]:
		if s == 0:
			ans[-1] = A[-1]
		elif s == 1:
			ans[-1] = B[-1]
		else:
			ans[-1] = C[-1]
		if ans[-1] == ans[-2]:
			ans[-1] = ans[0]
		s += 1
	print(*ans)


t = int(input())
for case in range(t):
	n = int(input())
	a = input().split(' ')
	b = input().split(' ')
	c = input().split(' ')
	ant = 'a'
	sol = []
	for i in range(n):
		if a[i] == ant:
			ant = b[i]
		else:
			ant = a[i]
		sol.append(ant)
	if ant == sol[0]:
		if c[-1] == sol[0] or c[-1] == sol[-2]:
			sol[-1] = b[-1]
		else:
			sol[-1] = c[-1]
	print(' '.join(sol))


t = int(input())
for g in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = []
	for i in range(n):
		if i == 0:
			l.append(a[0])
		elif i == n - 1:
			if a[i] != l[-1] and a[i] != l[0]:
				l.append(a[i])
			elif b[i] != l[-1] and b[i] != l[0]:
				l.append(b[i])
			elif c[i] != l[-1] and c[i] != l[0]:
				l.append(c[i])
		elif a[i] != l[-1]:
			l.append(a[i])
		elif b[i] != l[-1]:
			l.append(b[i])
		elif c[i] != l[-1]:
			l.append(c[i])
	print(*l)


import math
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	x = []
	for i in range(n):
		p = [a[i], b[i], c[i]]
		p = list(set(p))
		if i == 0:
			x.append(p[0])
		elif i == n - 1:
			l = len(x)
			for h in p:
				if h != x[0] and h != x[l - 1]:
					x.append(h)
					break
		else:
			l = len(x)
			for j in p:
				if j != x[l - 1]:
					x.append(j)
					break
		if len(x) == n:
			break
	print(*x)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(n):
		if a[i] == a[i - 1]:
			a[i] = b[i]
	if a[-1] == a[0]:
		a[-1] = c[-1]
	print(*a)


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	n = INT()
	arr = [ARR(), ARR(), ARR()]
	c = 0
	ans = [0] * n
	ans[0] = arr[c][0]
	for i in range(1, n):
		if ans[i - 1] == arr[c][i]:
			c = (c + 1) % 3
		ans[i] = arr[c][i]
	if ans[-1] == ans[0]:
		c = (c + 1) % 3
		ans[-1] = arr[c][-1]
		if ans[-1] == ans[-2]:
			c = (c + 1) % 3
			ans[-1] = arr[c][-1]
	print(JOIN(ans))


cases = int(input())
while cases:
	cases -= 1
	num = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, num):
		if a[i] != ans[-1]:
			ans.append(a[i])
		else:
			ans.append(b[i])
	if ans[0] == ans[-1]:
		if ans[-2] != c[-1]:
			ans[-1] = c[-1]
		elif ans[-2] != b[-1] and ans[0] != b[-1]:
			ans[-1] = b[-1]
		else:
			ans[-1] = a[-1]
	print(*ans)


from sys import stdin, stdout
from math import gcd
input = stdin.buffer.readline
for i in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	(*c,) = map(int, input().split())
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] == ans[-1]:
			ans.append(b[i])
		else:
			ans.append(a[i])
	if a[-1] == ans[-1] or a[-1] == ans[0]:
		if b[-1] == ans[-1] or b[-1] == ans[0]:
			ans.append(c[-1])
		else:
			ans.append(b[-1])
	else:
		ans.append(a[-1])
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for i in range(1, n - 1):
		if p[-1] == a[i]:
			p.append(b[i])
		else:
			p.append(a[i])
	x = [a[-1], b[-1], c[-1]]
	for i in range(3):
		if x[i] != p[-1] and x[i] != p[0]:
			p.append(x[i])
	for i in range(n):
		print(p[i], end=' ')


t = int(input())
for z in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	temp = []
	ans = []
	temp.append(a[0])
	temp.append(b[0])
	temp.append(c[0])
	temp = sorted(temp)
	ans.append(temp[0])
	for i in range(1, n - 1):
		temp = []
		temp.append(a[i])
		temp.append(b[i])
		temp.append(c[i])
		temp = sorted(temp)
		if temp[0] != ans[i - 1]:
			ans.append(temp[0])
		else:
			ans.append(temp[1])
	temp = []
	temp.append(a[n - 1])
	temp.append(b[n - 1])
	temp.append(c[n - 1])
	temp = sorted(temp)
	if temp[0] != ans[-1] and ans[0] != temp[0]:
		ans.append(temp[0])
	elif temp[1] != ans[-1] and ans[0] != temp[1]:
		ans.append(temp[1])
	else:
		ans.append(temp[2])
	s = ''
	for i in range(n):
		s = s + str(ans[i]) + ' '
	print(s)


import sys
try:
	sys.stdin = open('input.txt', 'r')
except FileNotFoundError:
	pass

def next_array():
	return [int(i) for i in input().split()]

def prefix(lst):
	assert len(lst)
	pre = [lst[0]]
	for i in range(1, len(lst)):
		pre.append(lst[i] + pre[i - 1])
	return pre

def solve():
	l = int(input())
	a = next_array()
	b = next_array()
	c = next_array()
	lst = [a, b, c]
	out = []
	for i in range(l):
		if i == 0:
			out.append(lst[0][0])
		elif i == l - 1:
			for j in range(3):
				if lst[j][i] != out[i - 1] and lst[j][i] != out[0]:
					out.append(lst[j][i])
					break
		elif i:
			for j in range(3):
				if lst[j][i] != out[i - 1]:
					out.append(lst[j][i])
					break
	print(' '.join((str(i) for i in out)))
test_cases = True
if test_cases:
	for i in range(int(input())):
		solve()
else:
	solve()


import sys, string
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi

def input():
	return sys.stdin.buffer.readline().strip()
from bisect import bisect_left, bisect_right
from operator import add
MOD = int(1000000000.0) + 7
INF = float('inf')

def solve():
	n = int(input())
	xd = []
	xd.append([int(x) for x in input().split()])
	xd.append([int(x) for x in input().split()])
	xd.append([int(x) for x in input().split()])
	ans = [xd[0][0]]
	for i in range(1, n):
		for j in range(3):
			if xd[j][i] != ans[-1] and xd[j][i] != ans[0]:
				ans.append(xd[j][i])
				break
	print(*ans)
T = 1
T = int(input())
for case in range(1, T + 1):
	ans = solve()


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = list(map(int, input().split()))
		l = []
		for i in range(n):
			if n - 1 > i > 0:
				if a[i] != l[i - 1]:
					l.append(a[i])
				elif b[i] != l[i - 1]:
					l.append(b[i])
				elif c[i] != l[i - 1]:
					l.append(c[i])
			elif i == n - 1:
				if a[i] != l[i - 1] and a[i] != l[0]:
					l.append(a[i])
				elif b[i] != l[i - 1] and b[i] != l[0]:
					l.append(b[i])
				elif c[i] != l[i - 1] and c[i] != l[0]:
					l.append(c[i])
			else:
				l.append(a[i])
		print(*l)
main()


t = int(input())
for hh in range(0, t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = [-1] * n
	for i in range(0, n):
		if a[i] == b[i] and b[i] == c[i]:
			p[i] = a[i]
	prev = -2
	for i in range(0, n):
		if p[i] == -1:
			li = []
			li.append(a[i])
			li.append(b[i])
			li.append(c[i])
			li.sort()
			for j in range(0, 3):
				if li[j] != prev:
					p[i] = li[j]
					break
		prev = p[i]
	prev = p[n - 2]
	prev2 = p[0]
	if p[n - 1] == p[0]:
		li = []
		li.append(a[i])
		li.append(b[i])
		li.append(c[i])
		li.sort()
		for j in range(0, 3):
			if li[j] != prev and li[j] != prev2:
				p[i] = li[j]
				break
	print(*p)


try:
	test = int(input())
	for _ in range(test):
		num = int(input())
		list1 = list(map(int, input().strip().split()))[:num]
		list2 = list(map(int, input().strip().split()))[:num]
		list3 = list(map(int, input().strip().split()))[:num]
		temp = []
		temp.append(list1[0])
		for i in range(1, num):
			if list1[i] != temp[-1]:
				temp.append(list1[i])
			elif list2[i] != temp[-1]:
				temp.append(list2[i])
			elif list3[i] != temp[-1]:
				temp.append(list3[i])
		if temp[-1] == temp[0]:
			if temp[-1] != list1[-1] and temp[-2] != list1[-1]:
				temp[-1] = list1[-1]
			elif temp[-1] != list2[-1] and temp[-2] != list2[-1]:
				temp[-1] = list2[-1]
			elif temp[-1] != list3[-1] and temp[-2] != list3[-1]:
				temp[-1] = list3[-1]
		for t in temp:
			print(t, end=' ')
		print()
except:
	pass


import sys
import math

def II():
	return int(sys.stdin.readline())

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

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

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	b = LI()
	c = LI()
	d = [a[0]]
	for i in range(1, n - 1):
		if a[i] != d[i - 1]:
			d.append(a[i])
		elif b[i] != d[i - 1]:
			d.append(b[i])
		else:
			d.append(c[i])
	if a[-1] != a[0] and a[-1] != d[-1]:
		d.append(a[-1])
	elif b[-1] != a[0] and b[-1] != d[-1]:
		d.append(b[-1])
	else:
		d.append(c[-1])
	print(*d)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	v = [[ai, bi, ci] for ((ai, bi), ci) in zip(zip(a, b), c)]
	p = [v[0][0]]
	for i in range(1, n - 1):
		for vx in v[i]:
			if vx != p[i - 1]:
				p.append(vx)
				break
	pv = p[n - 2]
	nv = p[0]
	for vx in v[-1]:
		if vx != pv and vx != nv:
			p.append(vx)
			break
	print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = []
	for j in range(n):
		if j == 0:
			l.append(a[j])
		else:
			m = len(l)
			if j == n - 1:
				if a[j] != l[m - 1] and a[j] != l[0]:
					l.append(a[j])
				elif b[j] != l[m - 1] and b[j] != l[0]:
					l.append(b[j])
				else:
					l.append(c[j])
				break
			if a[j] != l[m - 1]:
				l.append(a[j])
			elif b[j] != l[m - 1]:
				l.append(b[j])
			else:
				l.append(c[j])
	print(*l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	stack = []
	for i in range(n - 1):
		if not stack:
			stack.append(a[i])
		elif a[i] == stack[-1]:
			stack.append(b[i])
		else:
			stack.append(a[i])
	if a[-1] == stack[0] or a[-1] == stack[-1]:
		if b[-1] == stack[0] or b[-1] == stack[-1]:
			stack.append(c[-1])
		else:
			stack.append(b[-1])
	else:
		stack.append(a[-1])
	print(*stack)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	c = list(map(int, input().strip().split(' ')))
	p = []
	p.append(a[0])
	for j in range(1, n - 1):
		kk = p[j - 1]
		if a[j] != kk:
			p.append(a[j])
		elif b[j] != kk:
			p.append(b[j])
		elif c[j] != kk:
			p.append(c[j])
	kk = p[n - 2]
	kkk = p[0]
	if a[n - 1] != kk and a[n - 1] != kkk:
		p.append(a[n - 1])
	elif b[n - 1] != kk and b[n - 1] != kkk:
		p.append(b[n - 1])
	elif c[n - 1] != kk and c[n - 1] != kkk:
		p.append(c[n - 1])
	print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = [0 for i in range(n)]
	d[0] = a[0]
	for i in range(1, n):
		if d[i - 1] != a[i]:
			d[i] = a[i]
		elif d[i - 1] != b[i]:
			d[i] = b[i]
		else:
			d[i] = c[i]
	if d[-1] == d[0]:
		if d[-2] != c[-1]:
			d[-1] = c[-1]
		else:
			d[-1] = a[-1] + b[-1] - d[-1]
	for i in range(n):
		print(d[i], end=' ')
	print()


from sys import stdin
input = stdin.readline

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = []
	for i in range(len(a)):
		last = -1 if len(ans) == 0 else ans[-1]
		if a[i] != last:
			ans.append(a[i])
			continue
		if b[i] != last:
			ans.append(b[i])
			continue
		if c[i] != last:
			ans.append(c[i])
			continue
	if ans[-1] == ans[0]:
		if c[-1] != ans[-2] and c[-1] != ans[0]:
			ans[-1] = c[-1]
		if b[-1] != ans[-2] and b[-1] != ans[0]:
			ans[-1] = b[-1]
		if a[-1] != ans[-2] and a[-1] != ans[0]:
			ans[-1] = a[-1]
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


n = int(input())
i = 0
while i < n:
	k = int(input())
	mas_a = [int(j) for j in input().split()]
	mas_b = [int(j) for j in input().split()]
	mas_c = [int(j) for j in input().split()]
	mas_p = []
	mas_p.append(mas_a[0])
	mass_add = [0]
	j = 1
	add = 0
	otk = 0
	while j < k:
		if j == k - 1:
			if add == 1 and mas_p[-1] != mas_b[j] and (mas_p[0] != mas_b[j]):
				mas_p.append(mas_b[j])
				j += 1
				mass_add.append(1)
				otk = 0
			elif add == 2 and mas_p[-1] != mas_c[j] and (mas_p[0] != mas_c[j]):
				mas_p.append(mas_c[j])
				j += 1
				mass_add.append(2)
				otk = 0
			elif add == 0 and mas_p[-1] != mas_a[j] and (mas_p[0] != mas_a[j]):
				mas_p.append(mas_a[j])
				j += 1
				mass_add.append(0)
				otk = 0
			elif otk < 2:
				add = (add + 1) % 3
				otk += 1
			else:
				mas_p.pop()
				add = (mass_add.pop() + 1) % 3
				j -= 1
		elif add == 1 and mas_p[-1] != mas_b[j]:
			mas_p.append(mas_b[j])
			j += 1
			mass_add.append(1)
			otk = 0
		elif add == 2 and mas_p[-1] != mas_c[j]:
			mas_p.append(mas_c[j])
			j += 1
			mass_add.append(2)
			otk = 0
		elif add == 0 and mas_p[-1] != mas_a[j]:
			mas_p.append(mas_a[j])
			j += 1
			mass_add.append(0)
			otk = 0
		elif otk < 2:
			add = (add + 1) % 3
			otk += 1
		else:
			mas_p.pop()
			add = (mass_add.pop() + 1) % 3
			j -= 1
	for j in mas_p:
		print(j, end=' ')
	print()
	i += 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = [0] * n
	f = 0
	np = False
	res[0] = a[0]
	for i in range(1, n):
		if a[i] != res[i - 1] and a[i] != res[(i + 1) % n]:
			res[i] = a[i]
		elif b[i] != res[i - 1] and b[i] != res[(i + 1) % n]:
			res[i] = b[i]
		elif c[i] != res[i - 1] and c[i] != res[(i + 1) % n]:
			res[i] = c[i]
		else:
			np = True
	if np:
		np = False
		res[0] = b[0]
		for i in range(1, n):
			if a[i] != res[i - 1] and a[i] != res[(i + 1) % n]:
				res[i] = a[i]
			elif b[i] != res[i - 1] and b[i] != res[(i + 1) % n]:
				res[i] = b[i]
			elif c[i] != res[i - 1] and c[i] != res[(i + 1) % n]:
				res[i] = c[i]
			else:
				np = True
	if np:
		np = False
		res[0] = c[0]
		for i in range(1, n):
			if a[i] != res[i - 1] and a[i] != res[(i + 1) % n]:
				res[i] = a[i]
			elif b[i] != res[i - 1] and b[i] != res[(i + 1) % n]:
				res[i] = b[i]
			elif c[i] != res[i - 1] and c[i] != res[(i + 1) % n]:
				res[i] = c[i]
			else:
				np = True
	for i in range(n):
		print(res[i], end=' ')
	print()


t = int(input())
for you in range(t):
	n = int(input())
	a = input().split()
	ai = [int(i) for i in a]
	b = input().split()
	bi = [int(i) for i in b]
	c = input().split()
	ci = [int(i) for i in c]
	print(ai[0], end=' ')
	curr = ai[0]
	z = ai[0]
	for i in range(1, n):
		if bi[i] != curr and bi[i] != z:
			curr = bi[i]
			print(bi[i], end=' ')
		elif ci[i] != curr and ci[i] != z:
			curr = ci[i]
			print(ci[i], end=' ')
		else:
			curr = ai[i]
			print(ai[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	c = []
	prev = a[0]
	c.append(prev)
	for i in range(1, n - 1):
		if a[i] != prev:
			c.append(a[i])
			prev = a[i]
			continue
		if a1[i] != prev:
			c.append(a1[i])
			prev = a1[i]
			continue
		if a2[i] != prev:
			c.append(a2[i])
			prev = a2[i]
			continue
	d = [c[0], c[n - 2]]
	e = [a[n - 1], a1[n - 1], a2[n - 1]]
	for i in range(len(e)):
		if e[i] not in d:
			c.append(e[i])
			break
	print(*c)


def solve(a, b, c):
	first = a[0]
	print(first, end=' ')
	prev = first
	for i in range(1, len(a)):
		for x in [a[i], b[i], c[i]]:
			if x != prev and x != first:
				prev = x
				print(x, end=' ')
				break
	print()
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	solve(a, b, c)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	b = get_array()
	c = get_array()
	ans = [a[0]]
	for i in range(1, n - 1):
		if ans[-1] != a[i]:
			ans.append(a[i])
		elif ans[-1] != b[i]:
			ans.append(b[i])
		elif ans[-1] != c[i]:
			ans.append(c[i])
	if ans[0] != a[n - 1] and ans[-1] != a[n - 1]:
		ans.append(a[n - 1])
	elif ans[0] != b[n - 1] and ans[-1] != b[n - 1]:
		ans.append(b[n - 1])
	elif ans[0] != c[n - 1] and ans[-1] != c[n - 1]:
		ans.append(c[n - 1])
	print(*ans)


n = int(input())
for i in range(n):
	y = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	x = []
	y = []
	z = []
	for i in a:
		x.append(int(i))
	for i in b:
		y.append(int(i))
	for i in c:
		z.append(int(i))
	g = []
	g.append(x[0])
	for i in range(1, len(x)):
		g.append(x[i])
		if g[i - 1] == g[i] or g[0] == g[-1]:
			g.pop(-1)
			g.append(y[i])
		if g[i - 1] == g[i] or g[0] == g[-1]:
			g.pop(-1)
			g.append(z[i])
		if g[i - 1] == g[i] or g[0] == g[-1]:
			pass
	for i in g:
		print(i, end=' ')
	print()


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *

class Sol:

	def fun(self, a, b, c, n):
		self.ans = []
		self.flag = False

		def check(arr):
			for i in range(n):
				if arr[i % n] == arr[(i + 1) % n]:
					return False
			return True

		def fun(i, arr):
			if self.flag:
				return
			if i == n:
				if check(arr):
					self.ans = list(arr)
					self.flag = True
				return
			if len(arr) > 0:
				if a[i] != arr[-1]:
					arr.append(a[i])
					fun(i + 1, arr)
					arr.pop()
				if b[i] != arr[-1]:
					arr.append(b[i])
					fun(i + 1, arr)
					arr.pop()
				if c[i] != arr[-1]:
					arr.append(c[i])
					fun(i + 1, arr)
					arr.pop()
			else:
				arr.append(a[i])
				fun(i + 1, arr)
				arr.pop()
				arr.append(b[i])
				fun(i + 1, arr)
				arr.pop()
				arr.append(c[i])
				fun(i + 1, arr)
				arr.pop()
			return
		fun(0, [])
		print(*self.ans)
for _ in range(ii1()):
	n = ii1()
	a = iia()
	b = iia()
	c = iia()
	sol = Sol()
	sol.fun(a, b, c, n)


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(3):
		arr.append(list(map(int, input().split())))
	ans = [str(arr[0][0])]
	for i in range(1, n):
		for x in range(3):
			if i == n - 1:
				if arr[x][i] != int(ans[i - 1]) and arr[x][i] != int(ans[0]):
					ans.append(str(arr[x][i]))
					break
			elif arr[x][i] != int(ans[i - 1]):
				ans.append(str(arr[x][i]))
				break
	print(' '.join(ans))


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = [a[0]]
	f = 0
	for i in range(1, n - 1):
		if f == 0:
			if b[i] != d[i - 1]:
				d.append(b[i])
				f = 1
			else:
				d.append(c[i])
				f = 2
		elif f == 1:
			if a[i] != d[i - 1]:
				d.append(a[i])
				f = 0
			else:
				d.append(c[i])
				f = 2
		elif f == 2:
			if a[i] != d[i - 1]:
				d.append(a[i])
				f = 0
			else:
				d.append(b[i])
				f = 1
	if a[n - 1] != d[0] and a[n - 1] != d[n - 2]:
		d.append(a[n - 1])
	elif b[n - 1] != d[0] and b[n - 1] != d[n - 2]:
		d.append(b[n - 1])
	else:
		d.append(c[n - 1])
	print(*d)


from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

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

def inverse(N, mod):
	return pow(N, mod - 2, mod)

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = getlist()
		B = getlist()
		C = getlist()
		ans = []
		ans.append(A[0])
		for i in range(1, N - 1):
			if ans[-1] != A[i]:
				ans.append(A[i])
			else:
				ans.append(B[i])
		if A[N - 1] != ans[0] and A[N - 1] != ans[-1]:
			ans.append(A[N - 1])
		elif B[N - 1] != ans[0] and B[N - 1] != ans[-1]:
			ans.append(B[N - 1])
		else:
			ans.append(C[N - 1])
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	ans = [0] * n
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	ans[0] = a[0]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != ans[i - 1]:
				ans[i] = a[i]
			elif b[i] != ans[i - 1]:
				ans[i] = b[i]
			elif c[i] != ans[i - 1]:
				ans[i] = c[i]
		elif a[i] != ans[i - 1] and a[i] != ans[0]:
			ans[i] = a[i]
		elif b[i] != ans[i - 1] and b[i] != ans[0]:
			ans[i] = b[i]
		elif c[i] != ans[i - 1] and c[i] != ans[0]:
			ans[i] = c[i]
	for num in ans:
		print(num, end=' ')
	print()


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
q = I()
for _ in range(q):
	n = I()
	A = readInts()
	B = readInts()
	C = readInts()
	ans = []
	prv = None
	for i in range(n):
		(a, b, c) = (A[i], B[i], C[i])
		if i != n - 1:
			if a != prv:
				prv = a
				ans.append(a)
			elif b != prv:
				prv = b
				ans.append(b)
			elif c != prv:
				prv = c
				ans.append(c)
		elif a != prv and a != ans[0]:
			ans.append(a)
		elif b != prv and b != ans[0]:
			ans.append(b)
		elif c != prv and c != ans[0]:
			ans.append(c)
	print(*ans)


import sys as _sys

def main():
	t = int(input())
	for i_t in range(t):
		(n,) = _read_ints()
		a = tuple(_read_ints())
		b = tuple(_read_ints())
		c = tuple(_read_ints())
		result = find_p_sequence(a, b, c)
		print(*result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))

def find_p_sequence(a_seq, b_seq, c_seq):
	assert len(a_seq) == len(b_seq) == len(c_seq)
	n = len(a_seq)
	p = [None] * n
	p[0] = a_seq[0]
	for i in range(1, n - 1):
		if a_seq[i] != p[i - 1]:
			p[i] = a_seq[i]
		else:
			p[i] = b_seq[i]
	for seq in (a_seq, b_seq, c_seq):
		if seq[-1] != p[0] and seq[-1] != p[-2]:
			p[-1] = seq[-1]
			break
	return p
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = [-1 for i in range(n)]
	for i in range(n):
		if A[i] == B[i] == C[i]:
			ans[i] = A[i]
	for i in range(n):
		if ans[i] == -1 and (A[i] == B[i] or B[i] == C[i] or C[i] == A[i]):
			(v, m) = (max(A[i], B[i], C[i]), min(A[i], B[i], C[i]))
			if ans[(i + 1) % n] != v and ans[i - 1] != v:
				ans[i] = v
			else:
				ans[i] = m
	for i in range(n):
		if ans[i] == -1:
			(v, m, n1) = (A[i], B[i], C[i])
			if ans[(i + 1) % n] != v and ans[i - 1] != v:
				ans[i] = v
			elif ans[(i + 1) % n] != m and ans[i - 1] != m:
				ans[i] = m
			else:
				ans[i] = n1
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	z = [a[0]]
	for i in range(1, n - 1):
		if a[i] != z[i - 1]:
			z.append(a[i])
		else:
			z.append(b[i])
	if a[n - 1] != z[n - 2] and a[n - 1] != z[0]:
		z.append(a[n - 1])
	elif b[n - 1] != z[n - 2] and b[n - 1] != z[0]:
		z.append(b[n - 1])
	else:
		z.append(c[n - 1])
	print(' '.join([str(i) for i in z]))


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	b = list(map(int, I().split()))
	c = list(map(int, I().split()))
	ans = [a[0]]
	s = {a[0]}
	for i in range(1, n):
		ans.append(list({a[i], b[i], c[i]} - s)[0])
		s = {ans[i]}
	if ans[n - 1] == ans[0]:
		ans[n - 1] = list({a[n - 1], b[n - 1], c[n - 1]} - {ans[n - 1], ans[n - 2]})[0]
	print(*ans)


import random
sets = []
sizes_of_sequence = []
p_sets = []
number_of_sets = int(input())
for i in range(number_of_sets):
	sets.append([])
	size_of_sequence = int(input())
	sizes_of_sequence.append(size_of_sequence)
	sets[i].append(list(map(int, input().split())))
	sets[i].append(list(map(int, input().split())))
	sets[i].append(list(map(int, input().split())))
for i in range(len(sets)):
	[a, b, c] = sets[i]
	size = sizes_of_sequence[i]
	p_sets.append([0 for _ in range(size)])
	uniq_list = list(set(a + b + c))
	index = 0
	while index != size:
		p = random.choice(uniq_list)
		if p_sets[i][index % size - 1] != p and p_sets[i][0] != p and (p == a[index] or p == b[index] or p == c[index]):
			p_sets[i][index] = p
			index = index + 1
for p_set in p_sets:
	print(' '.join((str(e) for e in p_set)))


for _ in range(int(input())):
	n = int(input())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	third = list(map(int, input().split()))
	new = [first[0]]
	for i in range(1, n):
		temp = [first[i], second[i], third[i]]
		for p in temp:
			if p != new[i - 1]:
				new.append(p)
				break
	if new[0] == new[-1]:
		temp = [first[-1], second[-1], third[-1]]
		for i in temp:
			if i != new[0] and i != new[-2]:
				new[-1] = i
				break
	print(' '.join(map(str, new)))


from collections import deque

def ansarray(a, b, c):
	n = len(a)
	ans = deque()
	ans.append(a[0])
	for i in range(1, n):
		if i == n - 1:
			if a[i] != ans[0] and a[i] != ans[i - 1]:
				ans.append(a[i])
			elif b[i] != ans[0] and b[i] != ans[i - 1]:
				ans.append(b[i])
			else:
				ans.append(c[i])
		elif a[i] != ans[i - 1]:
			ans.append(a[i])
		elif b[i] != ans[i - 1]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	c = list(map(int, input().rstrip().split()))
	print(*ansarray(a, b, c))


mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	v = [-1 for i in range(n)]
	for i in range(n):
		if a[i] != v[(i - 1 + n) % n] and a[i] != v[(i + 1) % n]:
			v[i] = a[i]
		elif b[i] != v[(i - 1 + n) % n] and b[i] != v[(i + 1) % n]:
			v[i] = b[i]
		elif c[i] != v[(i - 1 + n) % n] and c[i] != v[(i + 1) % n]:
			v[i] = c[i]
	print(*v)
t = 1
t = int(input())
while t > 0:
	solve()
	t -= 1


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	c = list(map(int, stdin.readline().rstrip().split()))
	if n == 1:
		print(*a)
	for i in range(1, n):
		if a[i] == a[i - 1]:
			if a[i] != b[i]:
				a[i] = b[i]
			else:
				a[i] = c[i]
	if a[0] == a[-1]:
		if a[-1] != b[-1] and b[-1] != a[-2]:
			a[-1] = b[-1]
		elif a[-1] != c[-1] and c[-1] != a[-2]:
			a[-1] = c[-1]
	print(*a)


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(3):
		a.append(list(map(int, input().split())))
	ans = []
	ans.append(a[0][0])
	for j in range(1, n - 1):
		for i in range(3):
			if a[i][j] != ans[-1]:
				ans.append(a[i][j])
				break
	for j in range(3):
		if a[j][n - 1] not in [ans[0], ans[-1]]:
			ans.append(a[j][n - 1])
			break
	print(*ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left, bisect_right
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	n = I()
	arrA = L()
	arrB = L()
	arrC = L()
	arrP = [arrA[0]]
	flagEle = arrA[0]
	for i in range(1, n):
		if i == n - 1:
			for j in [arrA[i], arrB[i], arrC[i]]:
				if j != flagEle and j != arrP[0]:
					arrP.append(j)
					break
		else:
			for j in [arrA[i], arrB[i], arrC[i]]:
				if flagEle != j:
					flagEle = j
					arrP.append(j)
					break
	print(*arrP)

def main():
	for t in range(I()):
		myCode()
main()


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = li()
		c = li()
		aa = [-1] * n
		aa[0] = a[0]
		for i in range(1, n):
			if aa[i - 1] != a[i]:
				if i == n - 1:
					if aa[0] != a[i]:
						aa[i] = a[i]
				else:
					aa[i] = a[i]
			if aa[i - 1] != b[i]:
				if i == n - 1:
					if aa[0] != b[i]:
						aa[i] = b[i]
				else:
					aa[i] = b[i]
			if aa[i - 1] != c[i]:
				if i == n - 1:
					if aa[0] != c[i]:
						aa[i] = c[i]
				else:
					aa[i] = c[i]
		print(*aa)
main()


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

def solve(N, A, B, C):
	ABC = [A, B, C]
	ans = [A[0]]
	for i in range(1, N):
		for j in range(3):
			if ABC[j][i] != ans[i - 1] and (i != N - 1 or ABC[j][i] != ans[0]):
				ans.append(ABC[j][i])
				break
	assert len(ans) == N
	return ' '.join(map(str, ans))
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()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	ans = solve(N, A, B, C)
	print(ans)


for case in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = [a[0]] * n
	for i in range(1, n):
		if a[i] != ans[i - 1]:
			ans[i] = a[i]
		else:
			ans[i] = b[i]
	temp = set([a[-1], b[-1], c[-1]])
	try:
		temp.remove(ans[0])
	except KeyError:
		pass
	try:
		temp.remove(ans[-2])
	except KeyError:
		pass
	ans[-1] = list(temp)[0]
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = [-1000000000] * n
	l = []
	for i in range(n):
		l.append([a[i], b[i], c[i]])
	for i in range(n):
		if i == 0:
			ans[i] = l[0][0]
			continue
		if i == n - 1:
			for j in l[i]:
				if j != ans[i - 1] and j != ans[0]:
					ans[i] = j
					break
			continue
		for j in l[i]:
			if j != ans[i - 1]:
				ans[i] = j
				break
	print(*ans)


t = int(input())
ans = []
for test in range(t):
	n = int(input())
	L = []
	for i in range(3):
		L += [[int(i) for i in input().split(' ')]]
	ans += [[str(L[0][0])]]
	for i in range(1, n):
		if i != n - 1:
			if ans[test][-1] != str(L[0][i]):
				ans[test] += [str(L[0][i])]
			else:
				ans[test] += [str(L[1][i])]
		elif ans[test][-1] != str(L[0][i]) and ans[test][0] != str(L[0][i]):
			ans[test] += [str(L[0][i])]
		elif ans[test][-1] != str(L[1][i]) and ans[test][0] != str(L[1][i]):
			ans[test] += [str(L[1][i])]
		else:
			ans[test] += [str(L[2][i])]
for test in range(t):
	print(' '.join(ans[test]))


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	(*c,) = map(int, input().split())
	ans = []
	prev = a[-1]
	i = 0
	for (x, y, z) in zip(a, b, c):
		if i == n - 1:
			if b[-1] != ans[0] and b[-1] != prev:
				ans.append(b[-1])
			elif c[-1] != ans[0] and c[-1] != prev:
				ans.append(c[-1])
			else:
				ans.append(a[-1])
			break
		i += 1
		if x != prev:
			ans.append(x)
			prev = x
			continue
		if y != prev:
			ans.append(y)
			prev = y
			continue
		if z != prev:
			ans.append(z)
			prev = z
			continue
		i += 1
	print(*ans)


from collections import defaultdict

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	for i in range(n):
		if a[i] == b[i] == c[i]:
			ans[i] = a[i]
	prev = -1
	for i in range(n):
		if ans[i] == 0:
			if prev != a[i]:
				ans[i] = a[i]
			elif prev != b[i]:
				ans[i] = b[i]
			else:
				ans[i] = c[i]
		prev = ans[i]
	if ans[0] == ans[-1]:
		arr = [ans[0], ans[n - 2]]
		for i in [a[-1], b[-1], c[-1]]:
			if ans[0] != i and ans[n - 2] != i:
				ans[n - 1] = i
				break
	return ans
for j in range(int(input())):
	ans = solve()
	print(*ans)


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	res = [a[0]]
	for i in range(1, n):
		if a[i] != res[-1]:
			res.append(a[i])
		elif b[i] != res[-1]:
			res.append(b[i])
		else:
			res.append(c[i])
	if res[0] == res[-1]:
		if a[-1] != res[-2] and a[-1] != res[0]:
			res[-1] = a[-1]
		elif b[-1] != res[-2] and b[-1] != res[0]:
			res[-1] = b[-1]
		elif c[-1] != res[-2] and c[-1] != res[0]:
			res[-1] = c[-1]
	print(*res)


t = int(input())
for tc in range(t):
	n = int(input())
	line1 = input().split()
	line2 = input().split()
	line3 = input().split()
	(a, b, c, p) = ([], [], [], [-100])
	for i in range(n):
		a.append(int(line1[i]))
		b.append(int(line2[i]))
		c.append(int(line3[i]))
		arr = [a[-1], b[-1], c[-1]]
		for j in arr:
			if j != p[-1]:
				p.append(j)
				break
	p = p[1:]
	arr = [a[-1], b[-1], c[-1]]
	for i in range(3):
		if arr[i] != p[-2] and arr[i] != p[0]:
			p[-1] = arr[i]
			break
	for i in p:
		print(i, end=' ')
	print('')


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	ans = [A[0]]
	for i in range(1, N - 1):
		if B[i] != ans[i - 1]:
			ans.append(B[i])
		else:
			ans.append(A[i])
	if ans[-1] != C[N - 1] and ans[0] != C[N - 1]:
		ans.append(C[N - 1])
	elif ans[N - 2] != A[N - 1] and ans[0] != A[N - 1]:
		ans.append(A[N - 1])
	else:
		ans.append(B[N - 1])
	for a in ans:
		print(a, end=' ')
	print('')


n = int(input())
for i in range(n):
	l = int(input())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	arr3 = [int(x) for x in input().split()]
	p = [arr1[0]]
	for j in range(1, l):
		if j == l - 1:
			if p[j - 1] != arr1[j] and p[0] != arr1[j]:
				p.append(arr1[j])
			elif p[j - 1] != arr2[j] and p[0] != arr2[j]:
				p.append(arr2[j])
			else:
				p.append(arr3[j])
		elif p[j - 1] != arr1[j]:
			p.append(arr1[j])
		elif p[j - 1] != arr2[j]:
			p.append(arr2[j])
		else:
			p.append(arr3[j])
	print(*p)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	b = array()
	c = array()
	for i in range(1, n):
		if a[i] == a[i - 1]:
			a[i] = b[i]
	if a[-1] == a[0]:
		a[-1] = c[-1]
	if a[-1] == a[-2]:
		a[-1] = b[-1]
	print(*a)


for _ in range(int(input())):
	N = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	tobeprinted = []
	tobeprinted.append(a[0])
	for i in range(1, N - 1):
		if a[i] == tobeprinted[-1]:
			tobeprinted.append(b[i])
		else:
			tobeprinted.append(a[i])
	if a[-1] != tobeprinted[-1] and a[-1] != tobeprinted[0]:
		tobeprinted.append(a[-1])
	elif b[-1] != tobeprinted[-1] and b[-1] != tobeprinted[0]:
		tobeprinted.append(b[-1])
	else:
		tobeprinted.append(c[-1])
	print(*tobeprinted)


def answer(start):
	result = []
	result.append(start)
	for i in range(1, n):
		if seq1[i] != result[i - 1]:
			result.append(seq1[i])
		elif seq2[i] != result[i - 1]:
			result.append(seq2[i])
		elif seq3[i] != result[i - 1]:
			result.append(seq3[i])
	return result
t = int(input())
for _ in range(t):
	n = int(input())
	seq1 = [int(i) for i in input().split()]
	seq2 = [int(i) for i in input().split()]
	seq3 = [int(i) for i in input().split()]
	result1 = answer(seq1[0])
	result2 = answer(seq2[0])
	result3 = answer(seq3[0])
	if result1[0] != result1[n - 1]:
		for i in range(n):
			print(result1[i], end=' ')
	elif result2[0] != result2[n - 1]:
		for i in range(n):
			print(result2[i], end=' ')
	elif result3[0] != result3[n - 1]:
		for i in range(n):
			print(result3[i], end=' ')
	print()


for _ in [0] * int(input()):
	n = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	c = [*map(int, input().split())]
	p = [a[0]]
	for i in range(1, n):
		if p[-1] == a[i]:
			p.append(b[i])
		else:
			p.append(a[i])
	if p[0] == p[-1]:
		p[-1] = a[-1]
	if p[0] == p[-1] or p[-2] == p[-1]:
		p[-1] = b[-1]
	if p[0] == p[-1] or p[-2] == p[-1]:
		p[-1] = c[-1]
	print(*p)


t = int(input())

def solve(n, a, b, c):
	ans = [0] * n
	ans[0] = a[0]
	for i in range(n - 1):
		j = i + 1
		if a[j] != ans[i]:
			ans[j] = a[j]
		else:
			ans[j] = b[j]
	if c[n - 1] != ans[0] and c[n - 1] != ans[n - 2]:
		ans[n - 1] = c[n - 1]
	elif b[n - 1] != ans[0] and b[n - 1] != ans[n - 2]:
		ans[n - 1] = b[n - 1]
	else:
		ans[n - 1] = a[n - 1]
	print(' '.join([str(i) for i in ans]))
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	solve(n, a, b, c)


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	prev = -1
	ans = []
	k = int(stdin.readline())
	lst1 = [int(i) for i in stdin.readline().split()]
	lst2 = [int(i) for i in stdin.readline().split()]
	lst3 = [int(i) for i in stdin.readline().split()]
	for i in range(len(lst1)):
		if lst1[i] == prev:
			cur = lst2[i]
		else:
			cur = lst1[i]
		prev = cur
		ans += [cur]
	if ans[-1] == ans[0]:
		if lst2[-1] == ans[-2] or lst2[-1] == ans[0]:
			ans[-1] = lst3[-1]
		else:
			ans[-1] = lst2[-1]
	for num in ans:
		stdout.write(str(num) + ' ')
	stdout.write('\n')


t = int(input())
for _ in range(0, t):
	n = int(input())
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	ls3 = list(map(int, input().split()))
	p = []
	prev = -999
	for i in range(0, n - 1):
		if ls1[i] != prev:
			prev = ls1[i]
			print(ls1[i], end=' ')
			p.append(ls1[i])
		elif ls2[i] != prev:
			prev = ls2[i]
			print(ls2[i], end=' ')
			p.append(ls2[i])
		else:
			prev = ls3[i]
			print(ls3[i], end=' ')
			p.append(ls3[i])
	if ls1[-1] != p[0] and ls1[-1] != prev:
		print(ls1[-1])
	elif ls2[-1] != p[0] and ls2[-1] != prev:
		print(ls2[-1])
	elif ls3[-1] != p[0] and ls3[-1] != prev:
		print(ls3[-1])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	aList = [0] + list(map(int, input().rstrip().split()))
	bList = [0] + list(map(int, input().rstrip().split()))
	cList = [0] + list(map(int, input().rstrip().split()))
	ans = [0, aList[1]]
	for i in range(1, n):
		if ans[i] != aList[i + 1]:
			ans.append(aList[i + 1])
		elif ans[i] != bList[i + 1]:
			ans.append(bList[i + 1])
		elif ans[i] != cList[i + 1]:
			ans.append(cList[i + 1])
	if ans[-1] == ans[1]:
		ans.pop()
		if aList[-1] != ans[1] and aList[-1] != ans[-1]:
			ans.append(aList[-1])
		elif bList[-1] != ans[1] and bList[-1] != ans[-1]:
			ans.append(bList[-1])
		elif cList[-1] != ans[1] and cList[-1] != ans[-1]:
			ans.append(cList[-1])
	print(*ans[1:])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = [a, b, c]
	ans = [a[0]]
	for i in range(1, n - 1):
		for j in range(3):
			if l[j][i] != ans[-1]:
				ans.append(l[j][i])
				break
	for i in range(3):
		if l[i][-1] != ans[0] and l[i][-1] != ans[-1]:
			ans.append(l[i][-1])
			break
	print(*ans)


t = int(input())
while t > 0:
	n = int(input())
	s = [set() for i in range(n)]
	for i in range(3):
		a = [int(k) for k in input().split()]
		for j in range(n):
			s[j % n].add(a[j])
	c = -1
	for i in range(n - 1):
		u = list(s[i] - {c})[0]
		c = u
		if i == 0:
			v = c
		print(u, end=' ')
	print(list(s[n - 1] - {c, v})[0])
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	c = [int(j) for j in input().split()]
	p = [0] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p[i] = a[i]
		elif b[i] != p[i - 1]:
			p[i] = b[i]
		else:
			p[i] = c[i]
	if a[-1] != p[0] and a[-1] != p[-2]:
		p[-1] = a[-1]
	elif b[-1] != p[0] and b[-1] != p[-2]:
		p[-1] = b[-1]
	elif c[-1] != p[0] and c[-1] != p[-2]:
		p[-1] = c[-1]
	print(*p)


def solver():
	n = int(input())
	(arr1, arr2, arr3) = (list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())))
	ris = [0 for _ in range(n)]
	for x in range(n):
		if x != 0:
			die = x - 1
		else:
			die = n - 1
		ava = (x + 1) % n
		if arr1[x] != ris[die] and arr1[x] != ris[ava]:
			ris[x] = arr1[x]
		elif arr2[x] != ris[die] and arr2[x] != ris[ava]:
			ris[x] = arr2[x]
		if arr3[x] != ris[die] and arr3[x] != ris[ava]:
			ris[x] = arr3[x]
	print(*ris)
for _ in range(int(input())):
	solver()


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
import io
import os
import operator
input = sys.stdin.readline
import random
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	a = ain()
	b = ain()
	c = ain()
	prev = a[0]
	ans = [prev]
	for i in range(1, n):
		l = [a[i], b[i], c[i]]
		for j in l:
			if j != prev:
				if i == n - 1:
					if j != ans[0]:
						ans += [j]
						break
				else:
					ans += [j]
					prev = j
					break
	print(*ans)


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

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

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')

def inp():
	return sys.stdin.readline()

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())

def solve():
	n = itg()
	a = tuple(mpint())
	b = tuple(mpint())
	c = tuple(mpint())
	ans = [a[0]]
	for tp in zip(a[1:-1], b[1:-1], c[1:-1]):
		ans.append((set(tp) - {ans[-1]}).pop())
	ans.append(({a[-1], b[-1], c[-1]} - {ans[0], ans[-1]}).pop())
	return ans
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
for _ in range(itg()):
	print(*solve())


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = [a[0]]
	for i in range(1, n):
		if a[i] == d[i - 1]:
			d.append(b[i])
		else:
			d.append(a[i])
	if d[n - 1] == d[0]:
		d.pop()
		if d[-1] == c[n - 1]:
			d.append(b[n - 1])
		else:
			d.append(c[n - 1])
	print(*d)


def f(i, val, tmp):
	global ans
	if i == n:
		if tmp[0] != tmp[-1]:
			ans = tmp
			return True
		return False
	for ii in range(3):
		if a[i] != val and f(i + 1, a[i], tmp + [a[i]]):
			return True
		if b[i] != val and f(i + 1, b[i], tmp + [b[i]]):
			return True
		if c[i] != val and f(i + 1, c[i], tmp + [c[i]]):
			return True
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = []
	f(0, 0, [])
	print(*ans, sep=' ')


import sys
for i in range(0, int(sys.stdin.readline())):
	l = sys.stdin.readline()
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	c = list(map(int, sys.stdin.readline().split()))
	p = [0] * len(c)
	p[0] = a[0]
	for j in range(1, len(a) - 1):
		if a[j] != p[j - 1]:
			p[j] = a[j]
		else:
			p[j] = b[j]
	impossibles = [p[0], p[len(a) - 2]]
	possibles = [a[len(a) - 1], b[len(a) - 1], c[len(a) - 1]]
	for k in possibles:
		if not k in impossibles:
			p[len(a) - 1] = k
	out = ''
	for e in p:
		out += str(e)
		out += ' '
	out += '\n'
	sys.stdout.write(out)


import bisect
import array
import functools
import math
mo = 1000000007
T = int(input())
for Tid in range(T):
	n = int(input())
	a = array.array('i', map(int, input().split()))
	b = array.array('i', map(int, input().split()))
	c = array.array('i', map(int, input().split()))
	fi = a[0]
	la = a[0]
	print(a[0], end=' ')
	for i in range(1, n):
		v = 0
		if a[i] != fi and a[i] != la:
			v = a[i]
		if b[i] != fi and b[i] != la:
			v = b[i]
		if c[i] != fi and c[i] != la:
			v = c[i]
		print(v, end=' ')
		la = v
	print()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(ii()):
	n = ii()
	a = lii()
	b = lii()
	c = lii()
	arr = [a[0]]
	for i in range(1, n):
		prev = arr[i - 1]
		if i != n - 1:
			if a[i] == prev:
				arr.append(b[i])
			else:
				arr.append(a[i])
		else:
			next = arr[0]
			if a[i] != next and a[i] != prev:
				arr.append(a[i])
			elif b[i] != next and b[i] != prev:
				arr.append(b[i])
			else:
				arr.append(c[i])
	print(*arr)


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	n = inp()
	a = li()
	b = li()
	c = li()
	pre = -1
	ans = []
	for i in range(n):
		x = [a[i], b[i], c[i]]
		for j in x:
			if j != pre:
				ans.append(j)
				pre = j
				break
	if ans[0] == ans[-1]:
		p = ans[-2]
		x = [a[-1], b[-1], c[-1]]
		for i in x:
			if i != ans[0] and i != p:
				ans[-1] = i
				break
	print(*ans)
for _ in range(inp()):
	solve()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	a = l()
	b = l()
	c = l()
	answer = [a[0]]
	for i in range(1, n):
		if b[i] != answer[-1]:
			answer.append(b[i])
			continue
		if a[i] != answer[-1]:
			answer.append(a[i])
			continue
		answer.append(c[i])
	if answer[0] == answer[-1]:
		if answer[-1] == a[-1]:
			if b[-1] != answer[-2]:
				answer[-1] = b[-1]
			else:
				answer[-1] = c[-1]
		elif answer[-1] == b[-1]:
			if a[-1] != answer[-2]:
				answer[-1] = a[-1]
			else:
				answer[-1] = c[-1]
		elif b[-1] != answer[-2]:
			answer[-1] = b[-1]
		else:
			answer[-1] = a[-1]
	outa(*answer)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	st = []
	for i in range(n):
		st.append([a[i], b[i], c[i]])
	ans = [st[0][0]]
	for i in range(1, n):
		if i == n - 1:
			for j in st[i]:
				if j != ans[-1] and j != ans[0]:
					ans.append(j)
					break
		else:
			for j in st[i]:
				if j != ans[-1]:
					ans.append(j)
					break
	print(*ans)


T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	B = [int(_) for _ in input().split()]
	C = [int(_) for _ in input().split()]
	R = []
	for i in range(N):
		if i == 0:
			R.append(A[i])
			continue
		if i == N - 1:
			if A[i] != R[0] and A[i] != R[-1]:
				R.append(A[i])
			elif B[i] != R[0] and B[i] != R[-1]:
				R.append(B[i])
			else:
				R.append(C[i])
			continue
		if A[i] != R[-1]:
			R.append(A[i])
		else:
			R.append(B[i])
	print(' '.join(map(str, R)))


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k, modulus=1):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
		res %= modulus
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	this = []
	a = int_array()
	b = int_array()
	c = int_array()
	for i in range(n):
		this.append((a[i], b[i], c[i]))
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(this[i][0])
		elif i == n - 1:
			if ans:
				for j in this[i]:
					if j != ans[-1] and j != ans[0]:
						ans.append(j)
						break
		else:
			for j in this[i]:
				if j != ans[-1]:
					ans.append(j)
					break
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p_one = a[0]
	prev = p_one
	print(p_one, end=' ')
	for i in range(1, n - 1):
		x = a[i]
		y = b[i]
		z = c[i]
		if a[i] != prev:
			print(x, end=' ')
			prev = x
		elif b[i] != prev:
			print(y, end=' ')
			prev = y
		elif c[i] != prev:
			print(z, end=' ')
			prev = z
	if a[n - 1] != prev and a[n - 1] != p_one:
		print(a[n - 1], end=' ')
	elif b[n - 1] != prev and b[n - 1] != p_one:
		print(b[n - 1], end=' ')
	elif c[n - 1] != prev and c[n - 1] != p_one:
		print(c[n - 1], end=' ')
	print()


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.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(io.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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	P = []
	p = -1
	for (a, b) in zip(A, B[:-1]):
		if p != a:
			p_new = a
		else:
			p_new = b
		P.append(p_new)
		p = p_new
	(a, b, c) = (A[-1], B[-1], C[-1])
	p0 = P[0]
	if p != a and p0 != a:
		p_new = a
	elif p != b and p0 != b:
		p_new = b
	else:
		p_new = c
	P.append(p_new)
	print(' '.join(map(str, P)))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n - 1):
		if a[i] == p[i - 1]:
			p.append(b[i])
		else:
			p.append(a[i])
	checklist = (p[0], p[n - 2])
	if a[n - 1] not in checklist:
		p.append(a[n - 1])
	elif b[n - 1] not in checklist:
		p.append(b[n - 1])
	else:
		p.append(c[n - 1])
	print(*p)
for _ in range(int(input())):
	solve()


t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = list()
	for i in range(0, n - 1):
		try:
			if not a[i] == p[len(p) - 1]:
				p.append(a[i])
			elif not b[i] == p[len(p) - 1]:
				p.append(b[i])
			elif not c[i] == p[len(p) - 1]:
				p.append(c[i])
		except:
			p.append(a[i])
	n = n - 1
	if a[n] != b[n] and a[n] != c[n] and (b[n] != c[n]):
		if a[n] != p[n - 1] and a[n] != p[0]:
			p.append(a[n])
		elif b[n] != p[n - 1] and b[n] != p[0]:
			p.append(b[n])
		elif c[n] != p[n - 1] and c[n] != p[0]:
			p.append(c[n])
	print(' '.join(map(str, p)))


for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))
	ci = list(map(int, input().split()))
	pi = [ai[0]]
	for i in range(1, n):
		li = [ai[i], bi[i], ci[i]]
		for ii in li:
			if i == n - 1:
				if ii != pi[-1] and ii != pi[0]:
					pi.append(ii)
					break
			elif ii != pi[-1]:
				pi.append(ii)
				break
	print(*pi)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(map(int, input().split()))
	l = [arr[0]]
	i = 1
	while i < n:
		if i == n - 1:
			if arr[i] != l[-1] and arr[i] != l[0]:
				l.append(arr[i])
			elif brr[i] != l[-1] and brr[i] != l[0]:
				l.append(brr[i])
			elif crr[i] != l[-1] and crr[i] != l[0]:
				l.append(crr[i])
		elif arr[i] != l[-1]:
			l.append(arr[i])
		elif brr[i] != l[-1]:
			l.append(brr[i])
		elif crr[i] != l[-1]:
			l.append(crr[i])
		i += 1
	print(*l)


for _ in range(int(input())):
	n = int(input())
	mat = []
	temp = []
	for i in range(3):
		temp = list(map(int, input().split()))
		mat.append(temp)
		temp = []
	ind = 0
	r_ind = 0
	ret = [-1 for i in range(n)]
	prev = -1
	check_arr = [0 for j in range(n)]
	while ind < n:
		while check_arr[ind] < 3 and prev == mat[check_arr[ind]][ind]:
			check_arr[ind] += 1
		if check_arr[ind] == 3:
			check_arr[ind] = 0
			ind -= 1
			continue
		else:
			ret[ind] = mat[check_arr[ind]][ind]
			prev = mat[check_arr[ind]][ind]
		ind += 1
		if ind == n:
			if prev == mat[check_arr[0]][0]:
				check_arr[0] += 1
				ind = 0
	print(*ret)


from math import *

def inp():
	return int(input())

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

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

def p(x):
	print(x)
	return

def pl(x):
	print(*x)
	return

def main():
	for _ in range(inp()):
		n = inp()
		a = linp()
		b = linp()
		c = linp()
		p = [0 for i in range(n)]
		p[0] = a[0]
		for i in range(1, n):
			if i == n - 1:
				if p[i - 1] != a[i] and p[0] != a[i]:
					p[i] = a[i]
				elif p[i - 1] != b[i] and p[0] != b[i]:
					p[i] = b[i]
				else:
					p[i] = c[i]
			elif a[i] != p[i - 1]:
				p[i] = a[i]
			elif b[i] != p[i - 1]:
				p[i] = b[i]
			else:
				p[i] = c[i]
		pl(p)
main()


import os
import math
true = True
false = False
from functools import reduce
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins():
	return list(map(int, input_().split(' ')))

def inss():
	return list(input_().split(' '))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def ranin():
	return range(int(input_()))

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)
for _ in range(int(input_())):
	n = int(input_())
	a = ins()
	b = ins()
	c = ins()
	result = [a[-1]]
	for i in range(n - 1):
		ai = a[i]
		bi = b[i]
		ci = c[i]
		if ai != result[-1]:
			result.append(ai)
		elif bi != result[-1]:
			result.append(bi)
		elif ci != result[-1]:
			result.append(ci)
		else:
			raise Exception('Wrong answer')
	result.pop(0)
	ai = a[-1]
	bi = b[-1]
	ci = c[-1]
	if ai != result[0] and ai != result[-1]:
		result.append(ai)
	elif bi != result[0] and bi != result[-1]:
		result.append(bi)
	elif ci != result[0] and ci != result[-1]:
		result.append(ci)
	else:
		raise Exception('Wrong answer')
	print_(' '.join(map(str, result)))
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()


n = int(input())
for _ in range(n):
	a = []
	t = int(input())
	for _ in range(3):
		a.append(list(map(int, input().split())))
	l = [0] * t
	prev = 0
	for i in range(t):
		for j in range(3):
			if prev != a[j][i] and a[j][i] != l[(i + 1) % t]:
				l[i] = a[j][i]
				prev = a[j][i]
				break
			else:
				continue
	print(*l)


import sys, math
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	a = inpl()
	b = inpl()
	c = inpl()
	res = [a[0]]
	now = a[0]
	for i in range(1, n - 1):
		if a[i] != res[-1]:
			res.append(a[i])
		elif b[i] != res[-1]:
			res.append(b[i])
		else:
			res.append(c[i])
	if a[-1] != res[0] and a[-1] != res[-1]:
		res.append(a[-1])
	elif b[-1] != res[0] and b[-1] != res[-1]:
		res.append(b[-1])
	else:
		res.append(c[-1])
	print(*res)


t = int(input())
for i in range(t):
	ans = []
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	lst3 = list(map(int, input().split()))
	ans.append(max(lst1[0], lst2[0], lst3[0]))
	for i in range(1, n):
		a = max(lst1[i], lst2[i], lst3[i])
		if ans[-1] == a:
			ans.append(min(lst1[i], lst2[i], lst3[i]))
		else:
			ans.append(max(lst1[i], lst2[i], lst3[i]))
	if ans[-1] == ans[0]:
		a = lst1[-1]
		b = lst2[-1]
		c = lst3[-1]
		if a != ans[n - 2] and a != ans[0]:
			ans[-1] = a
		if b != ans[n - 2] and b != ans[0]:
			ans[-1] = b
		if c != ans[n - 2] and c != ans[0]:
			ans[-1] = c
	for i in range(len(ans)):
		print(ans[i], end=' ')


x = int(input())
num = []
a = []
b = []
c = []
number = -1
for i in range(0, x):
	num.append(int(input()))
	a.append(input().split())
	b.append(input().split())
	c.append(input().split())
for i in range(0, x):
	itog = ''
	num_i = num[i]
	a_i = a[i]
	b_i = b[i]
	c_i = c[i]
	pervoe = int(a_i[0])
	for m in range(0, num[i] - 1):
		if number != int(a_i[m]):
			itog = itog + a_i[m] + ' '
			number = int(a_i[m])
		elif number != int(b_i[m]):
			itog = itog + b_i[m] + ' '
			number = int(b_i[m])
		elif number != int(c_i[m]):
			itog = itog + c_i[m] + ' '
			number = int(c_i[m])
	if number != int(a_i[num[i] - 1]) != pervoe:
		itog = itog + a_i[num[i] - 1]
	elif number != int(b_i[num[i] - 1]) != pervoe:
		itog = itog + b_i[num[i] - 1]
	else:
		itog = itog + c_i[num[i] - 1]
	print(itog)
	number = -1


import sys
lines = sys.stdin.readlines()
cur_line = -1

def input():
	global lines, cur_line
	cur_line += 1
	return lines[cur_line][:-1]
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	r = [-1] * n
	r[0] = a[0]
	for i in range(n):
		r[i] = min([k for k in [a[i], b[i], c[i]] if not k in [r[i - 1], r[(i + 1) % n]]])
	print(*r)


t = int(input())
for _ in range(t):
	n = int(input())
	a = n * [None]
	temp = input().strip().split()
	for i in range(n):
		a[i] = 3 * [temp[i]]
	temp = input().strip().split()
	for i in range(n):
		a[i][1] = temp[i]
	temp = input().strip().split()
	for i in range(n):
		a[i][2] = temp[i]
	ans = n * [None]
	ans[0] = a[0][0]
	for i in range(1, n):
		for j in range(3):
			if ans[i - 1] != a[i][j]:
				ans[i] = a[i][j]
				break
	if ans[-1] == ans[0]:
		for j in range(3):
			if ans[-2] != a[-1][j] and ans[0] != a[-1][j]:
				ans[-1] = a[-1][j]
				break
	print(' '.join(ans))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

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

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	import sys
	import itertools as it
	import bisect as bi
	import math as mt
	import collections as cc
	input = sys.stdin.readline
	S = lambda : list(input().split())
	I = lambda : list(map(int, input().split()))
	for tc in range(int(input())):
		(n,) = I()
		a = I()
		b = I()
		c = I()
		for i in range(3):
			if i == 0:
				now = a[0]
			elif i == 1:
				now = b[0]
			else:
				now = c[0]
			temp = [now]
			for j in range(1, n - 1):
				if a[j] != temp[-1]:
					temp.append(a[j])
				elif b[j] != temp[-1]:
					temp.append(b[j])
				elif c[j] != temp[-1]:
					temp.append(c[j])
			last = temp[-1]
			then = temp[0]
			for ii in [a[-1], b[-1], c[-1]]:
				if ii != last and ii != then:
					temp.append(ii)
					break
			tf = 0
			if len(temp) == n:
				tf = 1
				print(*temp)
				break
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


nbTestCases = int(input())
for _ in range(nbTestCases):
	nbElements = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	res = []
	prev = 0
	for i in range(0, nbElements - 1):
		if a[i] != prev:
			res.append(a[i])
			prev = a[i]
		elif b[i] != prev:
			res.append(b[i])
			prev = b[i]
		elif c[i] != prev:
			res.append(c[i])
			prev = c[i]
	i = nbElements - 1
	if a[i] != prev and a[i] != res[0]:
		res.append(a[i])
	elif b[i] != prev and b[i] != res[0]:
		res.append(b[i])
	elif c[i] != prev and c[i] != res[0]:
		res.append(c[i])
	print(' '.join(map(str, res)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	lists = [a, b, c]
	on = 0
	new_list = [a[0]]
	for j in range(1, n):
		other1 = lists[(on + 1) % 3]
		other2 = lists[(on + 2) % 3]
		if other1[j] != new_list[j - 1]:
			new_list.append(other1[j])
			on = (on + 1) % 3
		else:
			new_list.append(other2[j])
			on = (on + 2) % 3
	if new_list[0] == new_list[n - 1]:
		if b[0] != new_list[1] and b[0] != new_list[n - 1]:
			new_list[0] = b[0]
		else:
			new_list[0] = c[0]
	print(' '.join(list(map(str, new_list))))


t = int(input())
sol = []
for i in range(t):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	for i in range(n):
		frente = i + 1
		if n == frente:
			frente = 0
		tras = i - 1
		if i == n - 1:
			if a[i] != sol[tras] and a[i] != sol[0]:
				if a[i] != a[frente] or a[i] != b[frente] or a[i] != c[frente]:
					sol.append(a[i])
			elif b[i] != sol[tras] and b[i] != sol[0]:
				if b[i] != a[frente] or b[i] != b[frente] or b[i] != c[frente]:
					sol.append(b[i])
			elif c[i] != sol[tras] and c[i] != sol[0]:
				if c[i] != a[frente] or c[i] != b[frente] or c[i] != c[frente]:
					sol.append(c[i])
		elif len(sol) > 0:
			if a[i] != sol[tras] and (a[i] != a[frente] or a[i] != b[frente] or a[i] != c[frente]):
				sol.append(a[i])
			elif b[i] != sol[tras] and (b[i] != a[frente] or b[i] != b[frente] or b[i] != c[frente]):
				sol.append(b[i])
			elif c[i] != sol[tras] and (c[i] != a[frente] or c[i] != b[frente] or c[i] != c[frente]):
				sol.append(c[i])
		elif a[i] != a[frente] or a[i] != b[frente] or a[i] != c[frente]:
			sol.append(a[i])
		elif b[i] != a[frente] or b[i] != b[frente] or b[i] != c[frente]:
			sol.append(b[i])
		elif c[i] != a[frente] or c[i] != b[frente] or c[i] != c[frente]:
			sol.append(c[i])
	print(*sol)
	sol.clear()


for _ in range(int(input())):
	N = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	C = [int(x) for x in input().split()]
	ans = [A[0]]
	for i in range(1, N - 1):
		if A[i] != ans[-1]:
			ans.append(A[i])
		elif B[i] != ans[-1]:
			ans.append(B[i])
		else:
			ans.append(C[i])
	if A[-1] != ans[-1] and ans[0] != A[-1]:
		ans.append(A[-1])
	elif B[-1] != ans[-1] and ans[0] != B[-1]:
		ans.append(B[-1])
	else:
		ans.append(C[-1])
	print(*ans)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans_list = [a[0]]
	for i in range(1, n):
		if a[i] not in [ans_list[i - 1], ans_list[0]]:
			ans_list.append(a[i])
		elif b[i] not in [ans_list[i - 1], ans_list[0]]:
			ans_list.append(b[i])
		elif c[i] not in [ans_list[i - 1], ans_list[0]]:
			ans_list.append(c[i])
	print(*ans_list)
T = int(input())
for _ in range(T):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	ans = [a[0]]
	for q in range(1, n):
		if q != n - 1:
			if a[q] != ans[-1]:
				ans.append(a[q])
			elif b[q] != ans[-1]:
				ans.append(b[q])
			else:
				ans.append(c[q])
		elif a[q] != ans[-1] and a[q] != ans[0]:
			ans.append(a[q])
		elif b[q] != ans[-1] and b[q] != ans[0]:
			ans.append(b[q])
		else:
			ans.append(c[q])
	for q in ans:
		print(q, end=' ')
	print()


from __future__ import division
from __future__ import print_function
from sys import stdin, stdout

def solver(n, arrayA, arrayB, arrayC):
	output = []
	for i in range(n):
		a = arrayA[i]
		b = arrayB[i]
		c = arrayC[i]
		options = [a, b, c]
		if len(output) == 0:
			output.append(options[0])
			continue
		if i + 1 == n:
			options.append(output[0])
		filtered_options = []
		for j in range(len(options)):
			next_candidate = options[j]
			if next_candidate == output[i - 1]:
				continue
			if i + 1 == n and next_candidate == output[0]:
				continue
			filtered_options.append(next_candidate)
		output.append(filtered_options[0])
	print(*output)

def main():
	t = int(input())
	args = []
	for i in range(t):
		n = int(input())
		arrayA = list(map(int, input().split()))
		arrayB = list(map(int, input().split()))
		arrayC = list(map(int, input().split()))
		solver(n, arrayA, arrayB, arrayC)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p.append(a[i])
		elif b[i] != p[i - 1]:
			p.append(b[i])
	last = []
	last.append(a[-1])
	last.append(b[-1])
	last.append(c[-1])
	if p[-1] in last:
		last.remove(p[-1])
	if p[0] in last:
		last.remove(p[0])
	p.append(last[0])
	print(*p)


def put():
	return [int(x) for x in input().split()]
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(put())
	b = list(put())
	c = list(put())
	first = a[0]
	prev = a[0]
	ans = [first]
	for i in range(1, n - 1):
		if a[i] != prev:
			prev = a[i]
		elif b[i] != prev:
			prev = b[i]
		else:
			prev = c[i]
		ans.append(prev)
	if a[n - 1] not in [first, prev]:
		ans.append(a[n - 1])
	elif b[n - 1] not in [first, prev]:
		ans.append(b[n - 1])
	else:
		ans.append(c[n - 1])
	print(*ans)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans1 = []
	prev = a[0]
	ans1.append(prev)
	for i in range(1, n):
		(opt1, opt2, opt3) = (a[i], b[i], c[i])
		if opt1 != prev:
			prev = opt1
		elif opt2 != prev:
			prev = opt2
		elif opt3 != prev:
			prev = opt3
		ans1.append(prev)
	if ans1[0] == ans1[-1]:
		ans1 = []
		prev = b[0]
		ans1.append(prev)
		for i in range(1, n):
			(opt1, opt2, opt3) = (a[i], b[i], c[i])
			if opt1 != prev:
				prev = opt1
			elif opt2 != prev:
				prev = opt2
			elif opt3 != prev:
				prev = opt3
			ans1.append(prev)
	if ans1[0] == ans1[-1]:
		ans1 = []
		prev = c[0]
		ans1.append(prev)
		for i in range(1, n):
			(opt1, opt2, opt3) = (a[i], b[i], c[i])
			if opt1 != prev:
				prev = opt1
			elif opt2 != prev:
				prev = opt2
			elif opt3 != prev:
				prev = opt3
			ans1.append(prev)
	print(*ans1)
	t -= 1


def sk(p):
	if k == 2:
		return 0
	return 1 if k == 0 else 2
t = int(input())
a = [0] * 3
for i in range(t):
	n = int(input())
	a[0] = list(map(int, input().split()))
	a[1] = list(map(int, input().split()))
	a[2] = list(map(int, input().split()))
	k = 0
	tm = []
	for j in range(n):
		if j == n - 1:
			if a[k][j] == tm[0]:
				k = sk(k)
				if a[k][j] == tm[n - 2]:
					k = sk(k)
				tm.append(a[k][j])
			else:
				tm.append(a[k][j])
			break
		tm.append(a[k][j])
		if a[k][j] == a[k][j + 1]:
			k = sk(k)
	for i in tm:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = [a[0]]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != p[i - 1] and a[i] != p[0]:
				p.append(a[i])
				continue
			if b[i] != p[i - 1] and b[i] != p[0]:
				p.append(b[i])
				continue
			if c[i] != p[i - 1] and c[i] != p[0]:
				p.append(c[i])
				continue
		if a[i] != p[i - 1]:
			p.append(a[i])
			continue
		if b[i] != p[i - 1]:
			p.append(b[i])
			continue
		if c[i] != p[i - 1]:
			p.append(c[i])
			continue
	print(*p)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n - 1):
		for j in [a[i], b[i], c[i]]:
			if j != ans[-1]:
				ans.append(j)
				break
	for j in [a[n - 1], b[n - 1], c[n - 1]]:
		if j != ans[0] and j != ans[-1]:
			ans.append(j)
			break
	print(*ans)


import os
from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.readlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx].strip()
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

def problem_solver():

	def solver(inpt):
		(n,) = inpt.array()
		a = [inpt.array(), inpt.array(), inpt.array()]
		k = 0
		p = [a[0][0]]
		for i in range(1, n):
			if i + 1 == n:
				while p[-1] == a[k][i] or p[0] == a[k][i]:
					k = (k + 1) % 3
			else:
				while p[-1] == a[k][i]:
					k = (k + 1) % 3
			p.append(a[k][i])
		print(*p)
	return solver
try:
	solver = problem_solver()
	for tc in Input().known_tests():
		solver(tc)
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = (list(map(int, input().split())) for _ in range(3))
	prev = None
	result = []
	for (ai, bi, ci) in zip(a, b, c):
		ri = next((x for x in [ai, bi, ci] if x != prev))
		prev = ri
		result.append(ri)
	result[0] = next((x for x in [a[0], b[0], c[0]] if x != result[1] and x != result[-1]))
	print(' '.join(map(str, result)))


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	n = int(input())
	l1 = list(put())
	l2 = list(put())
	l3 = list(put())
	ans = [l1[0]]
	for i in range(1, n):
		if i == n - 1:
			if l1[i] != ans[-1] and l1[i] != ans[0]:
				ans.append(l1[i])
			elif l2[i] != ans[-1] and l2[i] != ans[0]:
				ans.append(l2[i])
			else:
				ans.append(l3[i])
		elif l1[i] != ans[-1]:
			ans.append(l1[i])
		elif l2[i] != ans[-1]:
			ans.append(l2[i])
		else:
			ans.append(l3[i])
	mn = ''
	for i in range(n):
		mn += str(ans[i]) + ' '
	print(mn)


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import defaultdict
from pprint import pprint
from math import ceil

def main():
	n = int(input())
	arr = []
	arr.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
	t = 0
	prr = [-1] * n
	for i in range(n):
		while prr[(i - 1) % n] == arr[t][i] or prr[(i + 1) % n] == arr[t][i]:
			t += 1
			t %= 3
		prr[i] = arr[t][i]
	print(*prr)
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')
for _ in range(int(input())):
	main()


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	d = []
	for i in range(n):
		tmp = [a[i], b[i], c[i]]
		if i == 0:
			d.append(a[i])
			continue
		for j in tmp:
			if j != d[-1] and j != d[0]:
				d.append(j)
				break
	print(*d)


for tt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = a[0]
	for i in range(1, n):
		prev = ans[i - 1]
		if i != n - 1:
			if a[i] != prev:
				ans[i] = a[i]
			elif b[i] != prev:
				ans[i] = b[i]
			elif c[i] != prev:
				ans[i] != c[i]
		else:
			next = ans[0]
			if next != a[i] and prev != a[i]:
				ans[i] = a[i]
			elif next != b[i] and prev != b[i]:
				ans[i] = b[i]
			elif next != c[i] and prev != c[i]:
				ans[i] = c[i]
	print(*ans)


import math
teststring = '5\n3\n1 1 1\n2 2 2\n3 3 3\n4\n1 2 1 2\n2 1 2 1\n3 4 3 4\n7\n1 3 3 1 1 1 1\n2 4 4 3 2 2 4\n4 2 2 2 4 4 2\n3\n1 2 1\n2 3 3\n3 1 2\n10\n1 1 1 2 2 2 3 3 3 1\n2 2 2 3 3 3 1 1 1 2\n3 3 3 1 1 1 2 2 2 3\n'
online = __file__ != '/home/jhli/py/Grakn/Problem_A.py'
(true, false) = (True, False)
if True:

	def spitout():
		for c in teststring.splitlines():
			yield c
	_ito = spitout()
	if not online:

		def input():
			return next(_ito)

	def build_enum(*a):
		built = dict()
		for (i, c) in enumerate(a):
			built[c] = i
		return lambda x: built[x]
T = int(input())
for ti in range(1, T + 1):
	n = int(input())
	a = []
	b = []
	c = []
	p = []
	a.extend(map(int, input().split(' ')))
	b.extend(map(int, input().split(' ')))
	c.extend(map(int, input().split(' ')))
	l = len(a)
	p.append(a[0])
	for i in range(1, l - 1):
		if a[i] != p[i - 1]:
			p.append(a[i])
		elif b[i] != p[i - 1]:
			p.append(b[i])
		else:
			p.append(c[i])
	if l >= 2:
		if p[l - 2] != a[l - 1] and a[l - 1] != p[0]:
			p.append(a[l - 1])
		elif p[l - 2] != b[l - 1] and b[l - 1] != p[0]:
			p.append(b[l - 1])
		else:
			p.append(c[l - 1])
	print(' '.join(map(str, p)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	for i in range(n):
		if a[i] == b[i] == c[i]:
			ans[i] = a[i]
	prev = -1
	for i in range(n):
		if ans[i] == 0:
			if a[i] != prev:
				ans[i] = a[i]
				prev = ans[i]
			elif b[i] != prev:
				ans[i] = b[i]
				prev = ans[i]
			elif c[i] != prev:
				ans[i] = c[i]
				prev = ans[i]
		else:
			prev = ans[i]
	if ans[0] == ans[-1]:
		allr = [ans[0], ans[n - 2]]
		for el in [a[-1], b[-1], c[-1]]:
			if el not in allr:
				ans[-1] = el
				break
	print(*ans)


for i1 in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = []
	p.append(a[0])
	prev = a[0]
	first = a[0]
	i = 1
	while i < n:
		curr1 = a[i]
		curr2 = b[i]
		curr3 = c[i]
		if i == n - 1:
			if prev != curr1 and curr1 != first:
				p.append(curr1)
			elif prev != curr2 and curr2 != first:
				p.append(curr2)
			else:
				p.append(curr3)
			break
		if prev != curr1:
			p.append(curr1)
			prev = curr1
		elif prev != curr2:
			p.append(curr2)
			prev = curr2
		else:
			p.append(curr3)
			prev = curr3
		i += 1
	print(*p)


for test in range(int(input())):
	pocet = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	p = 0
	if a[0] != p:
		p = a[0]
		z = a[0]
		print(p, end=' ')
	else:
		p = b[0]
		z = b[0]
		print(p, end=' ')
	for i in range(1, pocet - 1):
		if a[i] != p:
			p = a[i]
			print(p, end=' ')
		else:
			p = b[i]
			print(p, end=' ')
	if a[pocet - 1] != p and a[pocet - 1] != z:
		p = a[pocet - 1]
		print(p)
	elif b[pocet - 1] != p and b[pocet - 1] != z:
		p = b[pocet - 1]
		print(p)
	else:
		print(c[pocet - 1])


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	c = list(map(int, stdin.readline().rstrip().split()))
	l = []

	def fuc(arr, i):
		global l
		if i > 1 and arr[i - 2] == arr[i - 1] or (i == n and arr[i - 1] == arr[0]) or len(l) > 0:
			return
		if i >= n:
			l += [arr]
			return
		fuc(arr + [a[i]], i + 1)
		fuc(arr + [b[i]], i + 1)
		fuc(arr + [c[i]], i + 1)
	fuc([], 0)
	for ele in l:
		if len(ele) == n:
			print(*ele)
			break


T = int(input())
for i in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	s = [a, b, c]
	p = 0
	ans = []
	ans.append(a[0])
	for j in range(1, N):
		if ans[-1] == s[p][j]:
			if p == 0:
				p = 1
			elif p == 1:
				p = 0
		ans.append(s[p][j])
	if ans[0] == ans[-1]:
		values = set([s[0][-1], s[1][-1], s[2][-1]])
		if ans[0] in values:
			values.remove(ans[0])
		if ans[-2] in values:
			values.remove(ans[-2])
		ans[-1] = list(values)[0]
	for k in ans:
		print(k, end=' ')
	print()


import sys
t = int(sys.stdin.readline().strip())
for i in range(t):
	n = int(sys.stdin.readline().strip())
	f = []
	s = []
	for j in range(3):
		s.append(list(map(int, sys.stdin.readline().split())))
	f.append(s[0][0])
	for j in range(1, n - 1):
		for k in range(3):
			if s[k][j] != f[j - 1]:
				f.append(s[k][j])
				break
	for k in range(3):
		if s[k][n - 1] != f[0] and s[k][n - 1] != f[n - 2]:
			f.append(s[k][n - 1])
			break
	for h in f:
		print(h, end=' ')
	print('')


def coloring(n, a, b, c):
	pool = a + b + c
	stack = [a[0]]
	(j, k, l) = (1, 1, 1)
	for i in range(1, n):
		if len(stack) == n - 1:
			if stack[0] == a[i]:
				j = 0
			elif stack[0] == b[i]:
				k = 0
			elif stack[0] == c[i]:
				l = 0
		if len(stack) == n:
			return stack
		if stack[-1] != a[i] and j:
			stack.append(a[i])
		elif stack[-1] != b[i] and k:
			stack.append(b[i])
		elif stack[-1] != c[i] and l:
			stack.append(c[i])
	return stack
n = int(input())
res = []
for i in range(n):
	p = int(input())
	num1 = list(map(int, input().split()))
	num2 = list(map(int, input().split()))
	num3 = list(map(int, input().split()))
	res.append(coloring(p, num1, num2, num3))
for j in res:
	print(*j)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	ans = [a[0]]
	for (i, j, k) in zip(a[1:], b[1:], c[1:]):
		if len(ans) == n - 1:
			if i != ans[-1] and i != ans[0]:
				ans.append(i)
			elif j != ans[-1] and j != ans[0]:
				ans.append(j)
			else:
				ans.append(k)
		elif i != ans[-1]:
			ans.append(i)
		elif j != ans[-1]:
			ans.append(j)
		else:
			ans.append(k)
	print(' '.join((str(i) for i in ans)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n - 1):
		if a[i] != ans[-1]:
			ans.append(a[i])
		else:
			ans.append(b[i])
	for el in [a[-1], b[-1], c[-1]]:
		if el != ans[0] and el != ans[-1]:
			ans.append(el)
			break
	print(*ans)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	b = list(mi())
	c = list(mi())
	ch = [0] * n
	out = [0] * n
	for i in range(n):
		ch[i] = list(set([a[i], b[i], c[i]]))
	out[0] = ch[0][0]
	for i in range(1, n):
		for j in ch[i]:
			if j != out[i - 1]:
				out[i] = j
	if out[-1] == out[0]:
		ch[-1].remove(out[-1])
		if n >= 2 and out[-2] in ch[-1]:
			ch[-1].remove(out[-2])
		out[-1] = ch[-1][0]
	print(*out)


import math
for _ in range(int(input())):
	ans = [0]
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for j in range(3):
		ans = [0]
		if j == 0:
			ans[0] = a[0]
		elif j == 1:
			ans[0] = b[0]
		else:
			ans[0] = c[0]
		for i in range(1, n):
			if b[i] != ans[i - 1]:
				ans.append(b[i])
			elif a[i] != ans[i - 1]:
				ans.append(a[i])
			elif c[i] != ans[i - 1]:
				ans.append(c[i])
		if ans[0] != ans[-1]:
			break
	print(*ans)


import sys
import itertools as it
import bisect as bi
import math as mt
import collections as cc
input = sys.stdin.readline
S = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	a = I()
	b = I()
	c = I()
	for i in range(3):
		if i == 0:
			now = a[0]
		elif i == 1:
			now = b[0]
		else:
			now = c[0]
		temp = [now]
		for j in range(1, n - 1):
			if a[j] != temp[-1]:
				temp.append(a[j])
			elif b[j] != temp[-1]:
				temp.append(b[j])
			elif c[j] != temp[-1]:
				temp.append(c[j])
		last = temp[-1]
		then = temp[0]
		for ii in [a[-1], b[-1], c[-1]]:
			if ii != last and ii != then:
				temp.append(ii)
				break
		tf = 0
		if len(temp) == n:
			tf = 1
			print(*temp)
			break


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	p = [A[0]]
	for i in range(1, n):
		for l in (A, B, C):
			if l[i] != p[-1]:
				p.append(l[i])
				break
		else:
			assert False
	for l in (A, B, C):
		if l[-1] != p[-2] and l[-1] != p[0]:
			p[-1] = l[-1]
			break
	else:
		assert False
	print(*p)


from math import *
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n - 1):
		if p[-1] != a[i]:
			p.append(a[i])
		elif p[-1] != b[i]:
			p.append(b[i])
		elif p[-1] != c[i]:
			p.append(c[i])
	i = n - 1
	if p[-1] != a[i] != p[0]:
		p.append(a[i])
	elif p[-1] != b[i] != p[0]:
		p.append(b[i])
	elif p[-1] != c[i] != p[0]:
		p.append(c[i])
	p = [str(i) for i in p]
	print(' '.join(p))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = list(map(int, input().split(' ')))
	ans = []
	for i in range(n):
		if i == 0:
			min_arr = sorted([a[i], b[i], c[i]])
			ans.append(min_arr[0])
		elif i == n - 1:
			min_arr = sorted([a[i], b[i], c[i]])
			for j in min_arr:
				if ans[i - 1] != j and ans[0] != j:
					ans.append(j)
					break
		else:
			min_arr = sorted([a[i], b[i], c[i]])
			for j in min_arr:
				if ans[i - 1] != j:
					ans.append(j)
					break
	for k in ans:
		print(k, end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	x = list()
	for _ in range(3):
		y = list(map(int, input().split()))
		x.append(y)
	(a, b, c) = (x[0], x[1], x[2])
	ans = list()
	for i in range(n):
		if len(ans) < 1:
			ans.append(a[0])
		elif len(ans) == n - 1:
			if ans[-1] != a[i] and ans[0] != a[i]:
				ans.append(a[i])
				continue
			elif ans[-1] != b[i] and ans[0] != b[i]:
				ans.append(b[i])
				continue
			elif ans[-1] != c[i] and ans[0] != c[i]:
				ans.append(c[i])
		elif ans[-1] != a[i]:
			ans.append(a[i])
			continue
		elif ans[-1] != b[i]:
			ans.append(b[i])
			continue
		elif ans[-1] != c[i]:
			ans.append(c[i])
	s = ''
	for i in ans:
		s += str(i) + ' '
	print(s)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	blst = list(map(int, input().split()))
	clst = list(map(int, input().split()))
	ans = [alst[0]]
	for (a, b) in zip(alst[1:-1], blst[1:-1]):
		if ans[-1] != a:
			ans.append(a)
		else:
			ans.append(b)
	for abc in [alst[-1], blst[-1], clst[-1]]:
		if abc == ans[0]:
			continue
		elif abc == ans[-1]:
			continue
		else:
			ans.append(abc)
			break
	print(*ans)
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	l = [a, b, c]
	sol = []
	for i in range(n):
		cur = i
		prev = (cur + n - 1) % n
		next = (cur + 1) % n
		for x in range(3):
			if l[x][cur] != -1:
				take = l[x][cur]
				break
		for x in range(3):
			if l[x][next] == take:
				l[x][next] = -1
			if l[x][prev] == take:
				l[x][prev] = -1
		sol.append(str(take))
	print(' '.join(sol))


t = int(input())
for _ in range(t):
	n = int(input())
	matrix = []
	for i in range(3):
		matrix.append([int(x) for x in input().split()])
	res = []
	res.append(matrix[0][0])
	c = 1
	while c < n:
		if c == n - 1:
			for r in range(3):
				if matrix[r][c] != res[-1] and matrix[r][c] != res[0]:
					res.append(matrix[r][c])
					break
		else:
			for r in range(3):
				if matrix[r][c] != res[-1]:
					res.append(matrix[r][c])
					break
		c = c + 1
	for item in res:
		print(item, end=' ')
	print()


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

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

def divi(n):
	ans = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			ans.append((i, n // i))
	return ans

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = li()
		c = li()
		ans = []
		for i in range(n):
			for j in (a[i], b[i], c[i]):
				if len(ans) == 0:
					ans.append(j)
					break
				elif i == n - 1:
					if ans[0] != j and ans[-1] != j:
						ans.append(j)
						break
				elif j != ans[-1]:
					ans.append(j)
					break
		print(*ans)
main()


from random import randint

def calc(a, b, c, n):
	sol = [0 for i in range(n)]
	f = randint(0, 2)
	if f == 0:
		sol[0] = a[0]
	if f == 1:
		sol[0] = b[0]
	if f == 2:
		sol[0] = c[0]
	for i in range(1, n):
		if i == n - 1:
			if sol[i - 1] != a[i] and sol[0] != a[i]:
				sol[i] = a[i]
			elif sol[i - 1] != b[i] and sol[0] != b[i]:
				sol[i] = b[i]
			else:
				sol[i] = c[i]
		elif sol[i - 1] != a[i]:
			sol[i] = a[i]
		elif sol[i - 1] != b[i]:
			sol[i] = b[i]
		else:
			sol[i] = c[i]
	print(*sol)
t = int(input())
for i in range(t):
	n = int(input())
	arr = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	calc(a, b, c, n)


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	d = {}
	a = list(map(int, input().split()))
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in b:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in c:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	prev = -1
	p = []
	for i in range(n):
		j = a[i]
		if i == n - 1 and p[0] != j and (prev != j):
			p.append(j)
			prev = j
			continue
		elif i != n - 1 and prev != j:
			p.append(j)
			prev = j
			continue
		j = b[i]
		if i == n - 1 and p[0] != j and (prev != j):
			p.append(j)
			prev = j
			continue
		elif i != n - 1 and prev != j:
			p.append(j)
			prev = j
			continue
		j = c[i]
		if i == n - 1 and p[0] != j and (prev != j):
			p.append(j)
			prev = j
			continue
		elif i != n - 1 and prev != j:
			p.append(j)
			prev = j
			continue
	for i in p:
		print(i, end=' ')
	print('')


for tt in range(int(input())):
	n = int(input())
	mat = []
	for i in range(3):
		mat.append(list(map(int, input().split())))
	mat1 = []
	for i in range(n):
		temp = []
		for j in mat:
			temp.append(j.pop(0))
		mat1.append(temp)
	ans = []
	for i in mat1:
		if not ans:
			ans.append(i.pop(0))
		else:
			for j in i:
				if ans[-1] != j and ans[0] != j:
					ans.append(j)
					break
	print(*ans)


y = lambda : [*map(int, input().split())]
for _ in range(int(input())):
	n = int(input())
	(a, b, c) = (y(), y(), y())
	j = [a[0]]
	for i in range(1, n - 1):
		if j[-1] != a[i]:
			j.append(a[i])
		else:
			j.append(b[i])
	if j[-1] != a[-1] and j[0] != a[-1]:
		j.append(a[-1])
	elif j[-1] != b[-1] and j[0] != b[-1]:
		j.append(b[-1])
	else:
		j.append(c[-1])
	print(' '.join(map(str, j)))


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arrayA = list(map(int, input().split()))
		arrayB = list(map(int, input().split()))
		arrayC = list(map(int, input().split()))
		res = [arrayA[0]]
		for i in range(1, n):
			if i == n - 1:
				tem = [res[i - 1], res[0]]
				if arrayA[i] in tem:
					if arrayB[i] in tem:
						res.append(arrayC[i])
					else:
						res.append(arrayB[i])
				else:
					res.append(arrayA[i])
			elif arrayA[i] == res[i - 1]:
				res.append(arrayB[i])
			else:
				res.append(arrayA[i])
		yield ' '.join([str(x) for x in res])
t = int(input())
ans = gift()
print(*ans, sep='\n')


test_cases = int(input())
for test_case in range(test_cases):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	x = [a, b, c]
	ans = [a[0]]
	for i in range(1, n):
		for j in range(3):
			if i != n - 1:
				if ans[-1] != x[j][i]:
					ans.append(x[j][i])
					break
			elif ans[-1] != x[j][i] and ans[0] != x[j][i]:
				ans.append(x[j][i])
				break
	print(*ans)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	p = []
	for i in range(n):
		if i == 0:
			p.append(a[i])
		elif i == n - 1:
			if p[-1] != a[i] and p[0] != a[i]:
				p.append(a[i])
			elif p[-1] != b[i] and p[0] != b[i]:
				p.append(b[i])
			else:
				p.append(c[i])
		elif p[-1] != a[i]:
			p.append(a[i])
		elif p[-1] != b[i]:
			p.append(b[i])
		else:
			p.append(c[i])
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	c = [*map(int, input().split())]
	p = [None] * n
	for i in range(n):
		for x in (a[i], b[i], c[i]):
			if p[i - 1] != x and p[(i + 1) % n] != x:
				p[i] = x
				break
	print(*p)


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	c = [int(x) for x in input().split(' ')]
	x = [a] + [b] + [c]
	j = 0
	ans = [x[0][0]]
	for i in range(1, n - 1):
		if x[j][i] == ans[-1]:
			j = (j + 1) % 3
		ans.append(x[j][i])
	while x[j][n - 1] in [ans[0], ans[-1]]:
		j = (j + 1) % 3
	ans.append(x[j][n - 1])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	prev = 0
	p = []
	for i in range(n):
		if i < n - 1:
			if a[i] != prev:
				p.append(a[i])
				prev = a[i]
			elif b[i] != prev:
				p.append(b[i])
				prev = b[i]
			elif c[i] != prev:
				p.append(c[i])
				prev = c[i]
		elif a[i] != prev and a[i] != p[0]:
			p.append(a[i])
			prev = a[i]
		elif b[i] != prev and b[i] != p[0]:
			p.append(b[i])
			prev = b[i]
		elif c[i] != prev and c[i] != p[0]:
			p.append(c[i])
			prev = c[i]
	print(' '.join([str(x) for x in p]))


for case in range(int(input())):
	N = int(input())
	arr_a = input().split()
	arr_b = list(input().split())
	arr_c = list(input().split())
	sol = []
	sol.append(arr_a[0])
	for i in range(1, N):
		if i != N - 1:
			if arr_a[i] != sol[i - 1]:
				sol.append(arr_a[i])
			elif arr_b[i] != sol[i - 1]:
				sol.append(arr_b[i])
			elif arr_c[i] != sol[i - 1]:
				sol.append(arr_c[i])
		elif arr_a[i] != sol[i - 1] and arr_a[i] != sol[0]:
			sol.append(arr_a[i])
		elif arr_b[i] != sol[i - 1] and arr_b[i] != sol[0]:
			sol.append(arr_b[i])
		elif arr_c[i] != sol[i - 1] and arr_c[i] != sol[0]:
			sol.append(arr_c[i])
	print(' '.join(sol))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	combined = list(zip(a, b, c))
	last = -1203232
	final = []
	for index in range(n):
		for number in combined[index]:
			adjacent = final[n - 1 - index] if index > n / 2 else last
			if number != last and number != adjacent:
				if index != n - 1:
					final.append(number)
					last = number
					break
				elif index == n - 1 and number != final[0]:
					final.append(number)
					break
	print(' '.join(map(str, final)))

def main():
	for _ in range(int(input())):
		solve()
main()


from sys import stdin, stdout
ans = []

def main():
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	p = [0] * n
	p[0] = a[0]
	for i in range(1, n):
		if a[i] != p[i - 1]:
			p[i] = a[i]
		elif b[i] != p[i - 1]:
			p[i] = b[i]
		else:
			p[i] = c[i]
	if p[0] == p[-1]:
		if a[-1] != p[0] and a[-1] != p[-2]:
			p[-1] = a[-1]
		elif b[-1] != p[0] and b[-1] != p[-2]:
			p[-1] = b[-1]
		else:
			p[-1] = c[-1]
	subans = ' '.join([str(x) for x in p])
	ans.append(subans)
for i in range(int(stdin.readline())):
	main()
stdout.write('\n'.join(ans))


import sys, math
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	N = getInt()
	A = getInts()
	B = getInts()
	C = getInts()
	ans = [A[0]]
	for j in range(1, N - 1):
		if A[j] != ans[-1]:
			ans.append(A[j])
		else:
			ans.append(B[j])
	if A[N - 1] not in (ans[N - 2], ans[0]):
		ans.append(A[N - 1])
	elif B[N - 1] not in (ans[N - 2], ans[0]):
		ans.append(B[N - 1])
	else:
		ans.append(C[N - 1])
	print(*ans)
for _ in range(getInt()):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	b = input().split()
	c = input().split()
	ans = [a[0]]
	for i in range(1, n):
		v = ans[-1]
		if i == n - 1:
			w = a[0]
			if not v == a[i] and (not w == a[i]):
				ans.append(a[i])
			elif not v == b[i] and (not w == b[i]):
				ans.append(b[i])
			else:
				ans.append(c[i])
		elif not v == a[i]:
			ans.append(a[i])
		elif not v == b[i]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	print(*ans)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	q = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	for i in range(q - 1):
		if a[i] == a[i + 1]:
			a[i + 1] = b[i + 1]
	if a[-1] == a[0]:
		if b[0] == a[1]:
			a[0] = c[0]
		else:
			a[0] = b[0]
	print(*a)


from math import *
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	b = LI()
	c = LI()
	d = []
	for i in range(n):
		if d == []:
			d += [a[i]]
			continue
		if i == n - 1:
			if a[i] != d[-1] and d[0] != a[i]:
				d += [a[i]]
			elif b[i] != d[-1] and d[0] != b[i]:
				d += [b[i]]
			elif c[i] != d[-1] and d[0] != c[i]:
				d += [c[i]]
		elif a[i] != d[-1]:
			d += [a[i]]
		elif b[i] != d[-1]:
			d += [c[i]]
		elif c[i] != d[-1]:
			d += [c[i]]
	print(*d)


import sys
import math
from collections import Counter
from collections import OrderedDict

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(inputt())
for _ in range(t):
	n = int(inputt())
	l1 = listt()
	l2 = listt()
	l3 = listt()
	l = [l1[0]]
	for i in range(n - 1):
		if i == n - 2:
			if l[0] != l1[i + 1] and l[i] != l1[i + 1]:
				l.append(l1[i + 1])
			elif l[0] != l2[i + 1] and l[i] != l2[i + 1]:
				l.append(l2[i + 1])
			elif l[0] != l3[i + 1] and l[i] != l3[i + 1]:
				l.append(l3[i + 1])
		elif l[i] != l1[i + 1]:
			l.append(l1[i + 1])
		elif l[i] != l2[i + 1]:
			l.append(l2[i + 1])
		elif l[i] != l3[i + 1]:
			l.append(l3[i + 1])
	print(*l)


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 print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = N()
	(a, b, c) = (RLL(), RLL(), RLL())
	res = [a[0]]
	for i in range(1, n - 1):
		last = res[-1]
		if a[i] == last:
			if b[i] == last:
				res.append(c[i])
			else:
				res.append(b[i])
		else:
			res.append(a[i])
	if a[-1] == res[-1] or a[-1] == res[0]:
		if b[-1] == res[-1] or b[-1] == res[0]:
			res.append(c[-1])
		else:
			res.append(b[-1])
	else:
		res.append(a[-1])
	print_list(res)


def circle(A, B, C, n):
	p = [A[0]]
	for i in range(1, n):
		if i == n - 1:
			if p[0] == A[i]:
				if p[-1] == B[i]:
					p.append(C[i])
				else:
					p.append(B[i])
			elif p[0] == B[i]:
				if p[-1] == C[i]:
					p.append(A[i])
				else:
					p.append(C[i])
			elif p[-1] == A[i]:
				p.append(B[i])
			else:
				p.append(A[i])
		elif p[-1] == A[i]:
			p.append(B[i])
		elif p[-1] == B[i]:
			p.append(C[i])
		else:
			p.append(A[i])
	print(*p)
for i in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = list(map(int, input().split()))
	circle(A, B, C, n)


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

def read_int():
	return int(input())
T = read_int()
for _ in range(T):
	n = read_int()
	a = list(read_ints())
	b = list(read_ints())
	c = list(read_ints())
	s = [a, b, c]
	ans = [0] * n
	for i in range(0, n):
		left = set((r[i - 1] for r in s))
		curr = set((r[i] for r in s))
		right = set((r[(i + 1) % n] for r in s))
		adjSet = set([ans[i - 1], ans[(i + 1) % n]])
		ok = curr.difference(left).difference(right).difference(adjSet)
		if ok:
			ans[i] = ok.pop()
			continue
		ok = curr.difference(left).difference(adjSet)
		if ok:
			ans[i] = ok.pop()
			continue
		ok = curr.difference(adjSet)
		if ok:
			ans[i] = ok.pop()
			continue
	print(*ans)


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

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	b = inputlist()
	c = inputlist()
	p = [0] * n
	p[0] = a[0]
	for i in range(1, n - 1):
		if a[i] != p[i - 1]:
			p[i] = a[i]
		elif b[i] != p[i - 1]:
			p[i] = b[i]
		elif c[i] != p[i - 1]:
			p[i] = c[i]
	if a[n - 1] != p[n - 2] and a[n - 1] != p[0]:
		p[n - 1] = a[n - 1]
	elif b[n - 1] != p[n - 2] and b[n - 1] != p[0]:
		p[n - 1] = b[n - 1]
	elif c[n - 1] != p[n - 2] and c[n - 1] != p[0]:
		p[n - 1] = c[n - 1]
	print(*p)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	p = [a[0]]
	for i in range(1, n):
		if i != n - 1:
			if p[i - 1] == a[i]:
				if p[i - 1] == b[i]:
					p.append(c[i])
				else:
					p.append(b[i])
			else:
				p.append(a[i])
		elif p[i - 1] == a[i] or p[0] == a[i]:
			if p[i - 1] == b[i] or p[0] == b[i]:
				p.append(c[i])
			else:
				p.append(b[i])
		else:
			p.append(a[i])
	print(*p)


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			n = int(R())
			a = [int(x) for x in R().split()]
			b = [int(x) for x in R().split()]
			c = [int(x) for x in R().split()]
			tmp = []
			for j in range(n):
				if j == 0:
					tmp.append(a[0])
				elif j == n - 1:
					if a[j] != tmp[0] and a[j] != tmp[n - 2]:
						tmp.append(a[j])
					elif b[j] != tmp[0] and b[j] != tmp[n - 2]:
						tmp.append(b[j])
					elif c[j] != tmp[0] and c[j] != tmp[n - 2]:
						tmp.append(c[j])
				elif tmp[j - 1] == a[j]:
					if tmp[j - 1] == b[j]:
						tmp.append(c[j])
					elif tmp[j - 1] == c[j]:
						tmp.append(b[j])
					else:
						tmp.append(b[j])
				elif tmp[j - 1] == b[j]:
					if tmp[j - 1] == c[j]:
						tmp.append(a[j])
					elif tmp[j - 1] == a[j]:
						tmp.append(c[j])
					else:
						tmp.append(c[j])
				elif tmp[j - 1] == c[j]:
					if tmp[j - 1] == a[j]:
						tmp.append(b[j])
					elif tmp[j - 1] == b[j]:
						tmp.append(a[j])
					else:
						tmp.append(a[j])
				else:
					tmp.append(a[j])
			print(*tmp)
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	a = inara()
	b = inara()
	c = inara()
	ans = []
	ans.append(a[0])
	for i in range(1, n):
		if ans[i - 1] != a[i]:
			ans.append(a[i])
		elif ans[i - 1] != b[i]:
			ans.append(b[i])
		else:
			ans.append[c[i]]
	for i in range(n - 1):
		print(ans[i], end=' ')
	if ans[-1] == ans[0]:
		if ans[0] != a[-1] and ans[-2] != a[-1]:
			print(a[-1])
		elif ans[0] != b[-1] and ans[-2] != b[-1]:
			print(b[-1])
		else:
			print(c[-1])
	else:
		print(ans[-1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	arr = [a, b, c]
	res = [0] * n
	res[0] = a[0]
	for i in range(n - 2):
		x = 0
		for j in range(3):
			if arr[j][i + 1] != res[i]:
				x = arr[j][i + 1]
		res[i + 1] = x
	for j in range(3):
		if arr[j][-1] != res[n - 2] and arr[j][-1] != res[0]:
			res[n - 1] = arr[j][-1]
	print(*res)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		l1 = list(In())
		l2 = list(In())
		ans = []
		for x in range(n):
			if x == 0:
				ans.append(l[0])
			elif x == n - 1:
				if ans[-1] != l[x] and l[x] != ans[0]:
					ans.append(l[x])
				elif ans[-1] != l1[x] and l1[x] != ans[0]:
					ans.append(l1[x])
				else:
					ans.append(l2[x])
			elif ans[-1] != l[x]:
				ans.append(l[x])
			elif ans[-1] != l1[x]:
				ans.append(l1[x])
			else:
				ans.append(l2[x])
		print(*ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


import sys, os, io

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

def ri():
	return int(sys.stdin.readline())

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		b = ria()
		c = ria()
		p = [a[0]]
		for i in range(1, n - 1):
			z = [a[i], b[i], c[i]]
			for j in z:
				if j != p[i - 1]:
					p.append(j)
					break
		i = -1
		z = [a[i], b[i], c[i]]
		for j in z:
			if j != p[-1] and j != a[0]:
				p.append(j)
				break
		print(*p)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(_) for _ in input().split()]
	b = [int(_) for _ in input().split()]
	c = [int(_) for _ in input().split()]
	arr = [a, b, c]
	p = []
	taken = 0
	for i in range(n):
		while p and p[i - 1] == arr[taken][i]:
			taken = (taken + 1) % 3
		p.append(arr[taken][i])
	while p[0] == p[-1] or p[-1] == p[-2]:
		taken = (taken + 1) % 3
		p[-1] = arr[taken][-1]
	print(*p, sep=' ')


def func(a, b, c):
	p = [i for i in a]
	lenp = len(p)
	for i in range(lenp - 1):
		next = (i + 1) % lenp
		if p[i] == p[next]:
			if p[i] != b[next]:
				p[next] = b[next]
			else:
				p[next] = c[next]
	if a[-1] != p[0] and a[-1] != p[-2]:
		p[-1] = a[-1]
	elif b[-1] != p[0] and b[-1] != p[-2]:
		p[-1] = b[-1]
	elif c[-1] != p[0] and c[-1] != p[-2]:
		p[-1] = c[-1]
	return p
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	c = list(map(int, input().rstrip().split()))
	print(' '.join(map(str, func(a, b, c))))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [0] * n
	ans[0] = max(a[0], b[0], c[0])
	for i in range(1, n):
		x = max(a[i], b[i], c[i])
		if i == n - 1:
			if a[i] != ans[i - 1] and a[i] != ans[0]:
				ans[i] = a[i]
			elif b[i] != ans[i - 1] and b[i] != ans[0]:
				ans[i] = b[i]
			else:
				ans[i] = c[i]
		elif x == ans[i - 1]:
			x = min(a[i], b[i], c[i])
			ans[i] = x
		else:
			ans[i] = x
	print(*ans)


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

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = inar()
		b = inar()
		c = inar()
		res = [a[0]] * n
		prev = a[0]
		for i in range(1, n):
			if a[i] != prev:
				prev = a[i]
			elif b[i] != prev:
				prev = b[i]
			elif c[i] != prev:
				prev = c[i]
			res[i] = prev
		(a1, b1, c1) = (a[-1], b[-1], c[-1])
		if res[0] == res[-1]:
			if a1 != res[0] and a1 != res[n - 2]:
				res[n - 1] = a1
			elif b1 != res[0] and b1 != res[n - 2]:
				res[n - 1] = b1
			elif c1 != res[0] and c1 != res[n - 2]:
				res[n - 1] = c1
		print(*res)
main()


import os
import sys
from io import BytesIO, IOBase
DEBUG_MODE = False

def main():
	T = iin()
	while T:
		T -= 1
		n = iin()
		(a, b, c) = (lin(), lin(), lin())
		for i in range(1, n):
			if a[i] == a[i - 1]:
				a[i] = b[i]
		if n > 1:
			if a[0] == a[-1] or a[0] == a[1]:
				a[0] = b[0]
			if a[0] == a[-1] or a[0] == a[1]:
				a[0] = c[0]
		print(*a)
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 iin():
	return int(input())

def lin():
	return list(map(int, input().split()))
if DEBUG_MODE == True:
	import cProfile
	cProfile.run('main()')
else:
	main()


for _ in range(int(input())):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	b = [0] + list(map(int, input().split()))
	c = [0] + list(map(int, input().split()))
	p = [0, a[1]]
	j = 2
	k = 2
	l = 2
	for i in range(2, n + 1):
		if i != n:
			if p[i - 1] != a[j]:
				p.append(a[j])
			elif p[i - 1] != b[k]:
				p.append(b[k])
			elif p[i - 1] != c[l]:
				p.append(c[l])
		elif p[i - 1] != a[j] and a[j] != p[i % n + 1]:
			p.append(a[j])
		elif p[i - 1] != b[k] and b[k] != p[i % n + 1]:
			p.append(b[k])
		elif p[i - 1] != c[l] and c[l] != p[i % n + 1]:
			p.append(c[l])
		j += 1
		l += 1
		k += 1
	print(*p[1:])


import sys
from sys import stdin, stdout, setrecursionlimit
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	c = list(map(int, stdin.readline().rstrip().split()))
	if n == 1:
		print(*a)
	for i in range(1, n):
		if a[i] == a[i - 1]:
			if a[i] != b[i]:
				a[i] = b[i]
			else:
				a[i] = c[i]
	if a[0] == a[-1]:
		if a[-1] != b[-1] and b[-1] != a[-2]:
			a[-1] = b[-1]
		elif a[-1] != c[-1] and c[-1] != a[-2]:
			a[-1] = c[-1]
	print(*a)


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	l = []
	for j in range(0, len(a)):
		if len(l) == 0:
			l.append(a[0])
		elif a[j] != l[-1]:
			l.append(a[j])
		elif b[j] != l[-1]:
			l.append(b[j])
		elif c[j] != l[-1]:
			l.append(c[j])
	if l[-1] == l[0]:
		if a[-1] != l[0] and a[-1] != l[-2]:
			l[-1] = a[-1]
		elif b[-1] != l[0] and b[-1] != l[-2]:
			l[-1] = b[-1]
		elif c[-1] != l[0] and c[-1] != l[-2]:
			l[-1] = c[-1]
	print(*l)


import sys
count = 0
num_1 = []
num_2 = []
num_3 = []
seq_length = 0
result = []

def solve(current_arr, current_index):
	if current_index >= 2:
		if current_arr[current_index - 2] == current_arr[current_index - 1]:
			return []
	if current_index == seq_length:
		if current_arr[0] != current_arr[seq_length - 1]:
			return current_arr
		else:
			return []
	return solve(current_arr + [num_1[current_index]], current_index + 1) or solve(current_arr + [num_2[current_index]], current_index + 1) or solve(current_arr + [num_3[current_index]], current_index + 1)
for line in sys.stdin:
	if count == 0:
		pass
	elif (count - 1) % 4 == 0:
		seq_length = int(line)
	elif (count - 1) % 4 == 1:
		num_1 = [int(i) for i in line.split(' ')]
	elif (count - 1) % 4 == 2:
		num_2 = [int(i) for i in line.split(' ')]
	elif (count - 1) % 4 == 3:
		num_3 = [int(i) for i in line.split(' ')]
		result = solve([], 0)
		for thing in result:
			print(thing, end=' ')
		print()
	count += 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	ans = []
	ans = [a[0]]
	for i in range(1, n):
		if ans[-1] != a[i]:
			ans.append(a[i])
		elif ans[-1] != b[i]:
			ans.append(b[i])
		else:
			ans.append(c[i])
	if len(ans) == 1:
		print(*ans, sep=' ')
	elif ans[0] != ans[-1]:
		print(*ans, sep=' ')
	else:
		ans[0] = b[0]
		if ans[0] == ans[1]:
			ans[0] = c[0]
		print(*ans, sep=' ')


t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	cur = -1
	res = [a[0]]
	for i in range(1, n - 1):
		num = i % n - 1
		if res[num] != a[i]:
			res.append(a[i])
		elif res[num] != b[i]:
			res.append(b[i])
		elif res[num] != c[i]:
			res.append(c[i])
	if a[n - 1] not in [res[0], res[-1]]:
		res.append(a[n - 1])
	elif b[n - 1] not in [res[0], res[-1]]:
		res.append(b[n - 1])
	elif c[n - 1] not in [res[0], res[-1]]:
		res.append(c[n - 1])
	for r in res:
		print(r, end=' ')
	print()


T_ON = 1
DEBUG_ON = 1
MOD = 998244353

def solve():
	n = read_int()
	A = read_ints()
	B = read_ints()
	C = read_ints()
	D = A[:]
	for i in range(1, n):
		if D[i] == D[i - 1]:
			D[i] = B[i]
	if D[-1] == D[-2] or D[-1] == D[0]:
		D[-1] = B[-1]
	if D[-1] == D[-2] or D[-1] == D[0]:
		D[-1] = C[-1]
	print_nums(D)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
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 read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

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

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

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

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	bar = [int(x) for x in input().split()]
	car = [int(x) for x in input().split()]
	past = 0
	fir = arr[0]
	for i in range(n - 1):
		if arr[i] != past:
			print(arr[i], end=' ')
			past = arr[i]
		elif bar[i] != past:
			print(bar[i], end=' ')
			past = bar[i]
		else:
			print(car[i], end=' ')
			past = car[i]
	if arr[-1] != past and arr[-1] != fir:
		print(arr[-1], end=' ')
	elif bar[-1] != past and bar[-1] != fir:
		print(bar[-1], end=' ')
	else:
		print(car[-1], end=' ')
	print()


tc = int(input())
for i in range(tc):
	size = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	i = 0
	for (x, y, z) in zip(a, b, c):
		if len(ans) == 0:
			ans.append(x)
			i += 1
		elif i != size - 1:
			if x != ans[i - 1]:
				ans.append(x)
				i += 1
			elif y != ans[i - 1]:
				ans.append(y)
				i += 1
			elif z != ans[i - 1]:
				ans.append(z)
				i += 1
		elif x != ans[i - 1] and x != ans[0]:
			ans.append(x)
			i += 1
		elif y != ans[i - 1] and y != ans[0]:
			ans.append(y)
			i += 1
		elif z != ans[i - 1] and z != ans[0]:
			ans.append(z)
			i += 1
	for i in ans:
		print(i, end=' ')
	print(' ')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	li = [[], [], []]
	li[0] = list(map(int, input().split()))
	li[1] = list(map(int, input().split()))
	li[2] = list(map(int, input().split()))
	ans = [0] * n
	for e in range(3):
		ans[0] = li[e][0]
		for i in range(1, n - 1):
			for ej in range(3):
				if li[ej][i] != ans[i - 1]:
					ans[i] = li[ej][i]
					break
		for i in range(3):
			if li[i][-1] != ans[n - 2] and li[i][-1] != ans[0]:
				ans[-1] = li[i][-1]
		good = True
		for i in range(n):
			good &= ans[i] != ans[(i + 1) % n]
		if good:
			print(*ans)
			break


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
GAP = 4
for t in [wtf[i:i + GAP] for i in range(1, len(wtf), GAP)]:
	n = int(t[0])
	MAT = [t[1].split(), t[2].split(), t[3].split()]
	ans = [MAT[0][0]]
	st = [1, 1, 1]
	for i in range(1, n):
		for j in range(3):
			if i + 1 == n:
				if MAT[j][st[j]] != ans[-1] and MAT[j][st[j]] != ans[0]:
					ans.append(MAT[j][st[j]])
					break
			elif MAT[j][st[j]] != ans[-1]:
				ans.append(MAT[j][st[j]])
				break
		st[0] += 1
		st[1] += 1
		st[2] += 1
	print(' '.join(ans))


for __ in range(int(input())):
	n = int(input())
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	ar3 = list(map(int, input().split()))
	ans = [ar1[0]]
	for i in range(1, n - 1):
		if ar1[i] != ans[-1]:
			ans.append(ar1[i])
		elif ar2[i] != ans[-1]:
			ans.append(ar2[i])
		elif ar3[i] != ans[-1]:
			ans.append(ar3[i])
	if ar1[-1] != ans[-1] and ar1[-1] != ans[0]:
		ans.append(ar1[-1])
	elif ar2[-1] != ans[-1] and ar2[-1] != ans[0]:
		ans.append(ar2[-1])
	elif ar3[-1] != ans[-1] and ar3[-1] != ans[0]:
		ans.append(ar3[-1])
	print(*ans)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = [a[0]]
	for i in range(1, n):
		t = [a[i], b[i], c[i]]
		k = 0
		for item in t:
			if k == 0:
				l = len(ans)
				if l == 1:
					if item != ans[0]:
						ans.append(item)
						k = 1
				elif l == n - 1:
					if item != ans[n - 2] and item != ans[0]:
						ans.append(item)
						k = 1
				elif item != ans[l - 1]:
					ans.append(item)
					k = 1
	for item in ans:
		print(item, end=' ')


def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	n = ii()
	a = li()
	b = li()
	c = li()
	p = [a[0]]
	for i in range(1, n - 1):
		if a[i] != p[-1]:
			p.append(a[i])
		elif b[i] != p[-1]:
			p.append(b[i])
		else:
			p.append(c[i])
	if a[n - 1] != p[-1] and a[n - 1] != p[0]:
		p.append(a[n - 1])
	elif b[n - 1] != p[-1] and b[n - 1] != p[0]:
		p.append(b[n - 1])
	else:
		p.append(c[n - 1])
	print(*p)


import sys, os
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def main():
	for _ in range(int(input())):
		n = int(input())
		a = read()
		b = read()
		c = read()
		ans = [a[0]]
		for i in range(1, n):
			last = ans[-1]
			for j in (a[i], b[i], c[i]):
				if last != j:
					ans.append(j)
					break
		for i in (a[-1], b[-1], c[-1]):
			if i != ans[-2] and i != ans[0]:
				ans[-1] = i
		print(*ans)
main()


def colour(tuples):
	length = len(tuples)

	def pick(idx, prev, first):
		if idx == length - 1:
			for n in tuples[idx]:
				if n != prev and n != first:
					yield [n]
		else:
			for n in tuples[idx]:
				if n != prev:
					for front in pick(idx + 1, n, first):
						front.append(n)
						yield front
	for first in tuples[0]:
		try:
			solution = next(pick(1, first, first))
			solution.append(first)
			return reversed(solution)
		except StopIteration:
			pass
t = int(input().rstrip())
for _ in range(t):
	_ = input()
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	c = list(map(int, input().rstrip().split()))
	solution = list(colour(list(zip(a, b, c))))
	print(' '.join(map(str, solution)))


import sys
T = int(input())
for t in range(T):
	N = int(input())
	mat = []
	for i in range(3):
		ar = [int(x) for x in input().split()]
		ar.append(ar[0])
		mat.append(ar)
	res = [0] * (N + 1)
	res[N] = res[0] = mat[0][0]
	for j in range(1, N):
		for i in range(3):
			if mat[i][j] != res[j - 1] and mat[i][j] != res[j + 1]:
				res[j] = mat[i][j]
				break
	res = [str(x) for x in res]
	print(' '.join(res[:N]))


for t in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = list(map(int, input().split()))
	ans = []
	for i in range(n):
		ele = [arr1[i], arr2[i], arr3[i]]
		if i == 0:
			ans.append(ele[0])
			continue
		elif i > 0 and i < n - 1:
			for j in ele:
				if ans[i - 1] == j:
					continue
				else:
					ans.append(j)
					break
		else:
			for j in ele:
				if ans[i - 1] == j or ans[0] == j:
					continue
				else:
					ans.append(j)
					break
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	pre = a[0]
	x = 1
	print(a[0], end=' ')
	for i in range(1, n - 1):
		if x == 1:
			if pre != a[i]:
				pre = a[i]
			else:
				x = 2
				pre = b[i]
		elif x == 2:
			if pre != b[i]:
				pre = b[i]
			else:
				x = 1
				pre = a[i]
		print(pre, end=' ')
	if pre != a[n - 1] and a[0] != a[n - 1]:
		print(a[n - 1])
	elif pre != b[n - 1] and a[0] != b[n - 1]:
		print(b[n - 1])
	else:
		print(c[n - 1])


test = int(input())
for q in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	x = [a[0] for i in range(n)]
	for i in range(1, n):
		if i == n - 1:
			if a[i] != x[0] and a[i] != x[i - 1]:
				x[i] = a[i]
			elif b[i] != x[0] and b[i] != x[i - 1]:
				x[i] = b[i]
			else:
				x[i] = c[i]
		elif a[i] != x[i - 1]:
			x[i] = a[i]
		elif b[i] != x[i - 1]:
			x[i] = b[i]
		else:
			x[i] = c[i]
	for i in range(len(x)):
		if i != len(x) - 1:
			print(x[i], end=' ')
		else:
			print(x[i])


import math
from collections import defaultdict
import functools as f
from itertools import permutations as p
t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = []
	for i in range(n):
		if i == 0:
			l.append(a[0])
		elif a[i] != l[i - 1]:
			l.append(a[i])
		elif b[i] != l[i - 1]:
			l.append(b[i])
		else:
			l.append(c[i])
	if l[-1] == l[0]:
		l.pop()
		if a[-1] != l[0]:
			l.append(a[-1])
			if l[-1] == l[-2]:
				l.pop()
				l.append(b[-1])
				if l[-1] == l[0]:
					l.pop()
					l.append(c[-1])
		elif b[-1] != l[0]:
			l.append(b[-1])
			if l[-1] == l[-2]:
				l.pop()
				l.append(c[-1])
		else:
			l.append(c[-1])
	print(*l)


from math import ceil as ce
m = int(input())
while m:
	m -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	j = a[0]
	for i in range(n - 1):
		if i == 0:
			print(j, end=' ')
			continue
		if b[i] != j:
			j = b[i]
			print(j, end=' ')
		elif a[i] != j:
			j = a[i]
			print(j, end=' ')
		elif c[i] != j:
			j = c[i]
			print(j, end=' ')
	if j != a[-1] and a[0] != a[-1]:
		print(a[-1])
	elif j != b[-1] and a[0] != b[-1]:
		print(b[-1])
	else:
		print(c[-1])


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	c = list(map(int, stdin.readline().split()))
	f = a[0]
	prev = 0
	for i in range(n - 1):
		if prev == a[i]:
			print(b[i], end=' ')
			prev = b[i]
		else:
			print(a[i], end=' ')
			prev = a[i]
	if a[n - 1] == prev or a[n - 1] == f:
		if b[n - 1] == f or b[n - 1] == prev:
			print(c[n - 1], end=' ')
		else:
			print(b[n - 1], end=' ')
	else:
		print(a[n - 1], end=' ')
	print()


tests = int(input())
for _ in range(0, tests):
	n = int(input())
	a = list(input().split())
	b = list(input().split())
	c = list(input().split())
	print(a[0], end=' ')
	curr = a[0]
	for i in range(1, n):
		if i != n - 1:
			if a[i] != curr:
				curr = a[i]
				print(a[i], end=' ')
			elif b[i] != curr:
				curr = b[i]
				print(b[i], end=' ')
			else:
				curr = c[i]
				print(c[i], end=' ')
		elif a[i] != a[0] and a[i] != curr:
			curr = a[i]
			print(a[i])
		elif b[i] != a[0] and b[i] != curr:
			curr = b[i]
			print(b[i])
		else:
			curr = c[i]
			print(c[i])


import sys
from collections import deque
from copy import *
from bisect import *

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

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

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	b = li()
	c = li()
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(a[i])
		elif i != n - 1:
			if ans[-1] == a[i]:
				ans.append(b[i])
			else:
				ans.append(a[i])
		else:
			p = [ans[0], ans[-1]]
			if a[i] not in p:
				ans.append(a[i])
			elif b[i] not in p:
				ans.append(b[i])
			else:
				ans.append(c[i])
	print(*ans)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	n = int(input())
	A = alele()
	B = alele()
	C = alele()
	Ans = [A[0]]
	for i in range(1, n):
		if i != n - 1:
			if A[i] != Ans[-1]:
				Ans.append(A[i])
			elif B[i] != Ans[-1]:
				Ans.append(B[i])
			else:
				Ans.append(C[i])
		elif A[i] != Ans[-1] and A[i] != Ans[0]:
			Ans.append(A[i])
		elif B[i] != Ans[-1] and B[i] != Ans[0]:
			Ans.append(B[i])
		else:
			Ans.append(C[i])
	print(*Ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(map(int, input().split()))
	m = list(map(int, input().split()))
	p = [l[0]]
	i = 1
	while i < n:
		if i == n - 1:
			if l[i] != p[0] and l[i] != p[i - 1]:
				p.append(l[i])
			elif s[i] != p[i - 1] and s[i] != p[0]:
				p.append(s[i])
			else:
				p.append(m[i])
			i += 1
		else:
			if l[i] != p[i - 1]:
				p.append(l[i])
			elif s[i] != p[i - 1]:
				p.append(s[i])
			else:
				p.append(m[i])
			i += 1
	print(*p)


for ad in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	l = [-1]
	for i in range(n - 1):
		if l[i] != a[i]:
			l.append(a[i])
		else:
			l.append(b[i])
	l.pop(0)
	if l[0] != a[n - 1] and l[-1] != a[n - 1]:
		l.append(a[n - 1])
	elif l[0] != b[n - 1] and l[-1] != b[n - 1]:
		l.append(b[n - 1])
	else:
		l.append(c[n - 1])
	for i in l:
		print(i, end=' ')
	print()


from collections import defaultdict

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
t = int(input())
for _ in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	ans = []
	for i in range(n):
		(a, b, c) = (l1[i], l2[i], l3[i])
		if ans == []:
			ans.append(a)
		elif i < n - 1:
			if a != ans[-1]:
				ans.append(a)
			elif b != ans[-1]:
				ans.append(b)
			elif c != ans[-1]:
				ans.append(c)
		elif i == n - 1:
			if ans[-1] != a and ans[0] != a:
				ans.append(a)
			elif b != ans[-1] and ans[0] != b:
				ans.append(b)
			elif c != ans[-1] and ans[0] != c:
				ans.append(c)
	while len(ans) != n:
		ans.pop()
	print(*ans)


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ans = []
	prev = -1
	for i in range(n - 1):
		if a[i] != prev:
			ans.append(a[i])
			prev = a[i]
		else:
			ans.append(b[i])
			prev = b[i]
	if a[-1] != ans[-1] and a[-1] != ans[0]:
		ans.append(a[-1])
	elif b[-1] != ans[-1] and b[-1] != ans[0]:
		ans.append(b[-1])
	else:
		ans.append(c[-1])
	print(*ans)


import sys

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

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	N = INT()
	A = LIST()
	B = LIST()
	C = LIST()
	ans = [A[0]]
	for i in range(1, N - 1):
		if ans[-1] != A[i]:
			ans.append(A[i])
		else:
			ans.append(B[i])
	if ans[-1] != A[-1] and A[-1] != ans[0]:
		ans.append(A[-1])
	elif ans[-1] != B[-1] and B[-1] != ans[0]:
		ans.append(B[-1])
	else:
		ans.append(C[-1])
	print(*ans)


from sys import maxsize
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	ar1 = [maxsize] * n
	ar1[-1] = a[-1]
	for i in range(n - 1):
		if a[i] != ar1[i - 1] and a[i] != ar1[i + 1]:
			ar1[i] = a[i]
		elif b[i] != ar1[i - 1] and b[i] != ar1[i + 1]:
			ar1[i] = b[i]
		else:
			ar1[i] = c[i]
	print(*ar1)