When Masha came to math classes today, she saw two integer sequences of length $n - 1$ on the blackboard. Let's denote the elements of the first sequence as $a_i$ ($0 \le a_i \le 3$), and the elements of the second sequence as $b_i$ ($0 \le b_i \le 3$).

Masha became interested if or not there is an integer sequence of length $n$, which elements we will denote as $t_i$ ($0 \le t_i \le 3$), so that for every $i$ ($1 \le i \le n - 1$) the following is true:   $a_i = t_i | t_{i + 1}$ (where $|$ denotes the bitwise OR operation) and  $b_i = t_i \& t_{i + 1}$ (where $\&$ denotes the bitwise AND operation). 

The question appeared to be too difficult for Masha, so now she asked you to check whether such a sequence $t_i$ of length $n$ exists. If it exists, find such a sequence. If there are multiple such sequences, find any of them.


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 10^5$) — the length of the sequence $t_i$. 

The second line contains $n - 1$ integers $a_1, a_2, \ldots, a_{n-1}$ ($0 \le a_i \le 3$) — the first sequence on the blackboard.

The third line contains $n - 1$ integers $b_1, b_2, \ldots, b_{n-1}$ ($0 \le b_i \le 3$) — the second sequence on the blackboard.


-----Output-----

In the first line print "YES" (without quotes), if there is a sequence $t_i$ that satisfies the conditions from the statements, and "NO" (without quotes), if there is no such sequence.

If there is such a sequence, on the second line print $n$ integers $t_1, t_2, \ldots, t_n$ ($0 \le t_i \le 3$) — the sequence that satisfies the statements conditions.

If there are multiple answers, print any of them.


-----Examples-----
Input
4
3 3 2
1 2 0

Output
YES
1 3 2 0 
Input
3
1 3
3 2

Output
NO


-----Note-----

In the first example it's easy to see that the sequence from output satisfies the given conditions:   $t_1 | t_2 = (01_2) | (11_2) = (11_2) = 3 = a_1$ and $t_1 \& t_2 = (01_2) \& (11_2) = (01_2) = 1 = b_1$;  $t_2 | t_3 = (11_2) | (10_2) = (11_2) = 3 = a_2$ and $t_2 \& t_3 = (11_2) \& (10_2) = (10_2) = 2 = b_2$;  $t_3 | t_4 = (10_2) | (00_2) = (10_2) = 2 = a_3$ and $t_3 \& t_4 = (10_2) \& (00_2) = (00_2) = 0 = b_3$. 

In the second example there is no such sequence.

Difficulty: interview

Starter code:

Solutions:
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

def try_solve(t):
    for i in range(n-1):
        ok = False

        for x in range(4):
            if a[i] == t[i] | x and b[i] == t[i] & x:
                t.append(x)
                ok = True
                break

        if not ok:
            return False

    return True

ok = False

for x in range(4):
    t = [x]

    if try_solve(t):
        print("YES")
        print(" ".join(map(str, t)))
        ok = True
        break

if not ok:
    print("NO")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

res = []
flag = True

for i in range(4):
    if len(res) == n:
        flag = True
        break
    flag = True
    res = [i]
    for k in range(0, n-1):
        if not flag:
            break
        for j in range(4):
            if (res[k] & j) == b[k] and (res[k] | j) == a[k]:
                res.append(j)
                break
        else:
            flag = False

if flag:
    print("YES")
    print(*res)
else:
    print("NO")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = [0]*(len(a)+1)

valids = dict()
for a1 in range(4):
	for b1 in range(4):
		valids[str(a1)+str(b1)] = list()
		for t1 in range(4):
			for t2 in range(4):
				if (t1 | t2 == a1 and t1 & t2 == b1):
					valids[str(a1)+str(b1)].append(str(t1) + str(t2))

prevs = ['0', '1', '2', '3']
# print(valids)
for i in range(0, len(a)):
	# valids = list()
	# for p in range(4):
	# 	for t in range(4):
	# 		if (p | t == a[i] and p & t == b[i]):
	# 			valids.append(p+t)
	newprevs = list()
	for i in valids[str(a[i])+str(b[i])]:
		for j in prevs:
			if j[-1] == i[0]:
				newprevs.append(str(j) + str(i[1]))
				# print(i, j)
				break
	prevs = newprevs

if (len(prevs) > 0):
	print('YES')
	print(' '.join(prevs[0]))
else:
	print('NO') 

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

pos_and = [
    {(0, 1), (0, 2), (0, 3), (0, 0), (1, 2)},
    {(1, 3), (1, 1)},
    {(2, 3), (2, 2)},
    {(3, 3)}
]
pos_or = [
    {(0, 0)},
    {(0, 1), (1, 1)},
    {(0, 2), (2, 2)},
    {(0, 3), (1, 3), (2, 3), (3, 3), (1, 2)}
]

# for i in range(4):
#     for j in range(4):
#         print(i, j, [x for x in pos_and[i].intersection(pos_or[j])])

res1 = []
flag1 = False
for i in range(n - 1):
    pairs = [x for x in pos_and[b[i]].intersection(pos_or[a[i]])]
    pairs.sort()
    if len(pairs) == 0:
        flag1 = True
        break
    for pair in pairs:
        rev_pair = (pair[1], pair[0])
        if len(res1) == 0:
            res1.append(pair[0])
            res1.append(pair[1])
            break
        if res1[-1] == pair[0]:
            res1.append(pair[1])
            break
        elif res1[-1] == rev_pair[0]:
            res1.append(rev_pair[1])
            break
    if len(res1) != i + 2:
        flag1 = True
        break
res2 = []
flag2 = False
for i in range(n - 1):
    pairs = [x for x in pos_and[b[i]].intersection(pos_or[a[i]])]
    pairs.sort()
    if len(pairs) == 0:
        flag2 = True
        break
    for pair in pairs:
        rev_pair = (pair[1], pair[0])
        if len(res2) == 0:
            res2.append(rev_pair[0])
            res2.append(rev_pair[1])
            break
        if res2[-1] == pair[0]:
            res2.append(pair[1])
            break
        elif res2[-1] == rev_pair[0]:
            res2.append(rev_pair[1])
            break
    if len(res2) != i + 2:
        flag2 = True
        break
if flag1 and flag2 and a[0] == 3 and b[0] == 0:
    res1 = []
    flag1 = False
    for i in range(n - 1):
        pairs = [x for x in pos_and[b[i]].intersection(pos_or[a[i]])]
        pairs.sort()
        if len(pairs) == 0:
            flag1 = True
            break
        for pair in pairs:
            rev_pair = (pair[1], pair[0])
            if len(res1) == 0:
                res1.append(pairs[1][0])
                res1.append(pairs[1][1])
                break
            if res1[-1] == pair[0]:
                res1.append(pair[1])
                break
            elif res1[-1] == rev_pair[0]:
                res1.append(rev_pair[1])
                break
        if len(res1) != i + 2:
            flag1 = True
            break
    res2 = []
    flag2 = False
    for i in range(n - 1):
        pairs = [x for x in pos_and[b[i]].intersection(pos_or[a[i]])]
        pairs.sort()
        if len(pairs) == 0:
            flag2 = True
            break
        for pair in pairs:
            rev_pair = (pair[1], pair[0])
            if len(res2) == 0:
                res2.append(pairs[1][1])
                res2.append(pairs[1][0])
                break
            if res2[-1] == pair[0]:
                res2.append(pair[1])
                break
            elif res2[-1] == rev_pair[0]:
                res2.append(rev_pair[1])
                break
        if len(res2) != i + 2:
            flag2 = True
            break
if not flag2:
    print("YES")
    print(*res2)
elif not flag1:
    print("YES")
    print(*res1)
else:
    print("NO")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for k in range(4):
    t = [-1] * n
    t[0] = k
    x = False
    for i in range(1, n):
        x = False
        for j in range(4):
            if a[i-1] == (j | t[i - 1]) and b[i-1] == (j & t[i - 1]):
                t[i] = j
                x = True
        if not x:
            break
    if x:
        print("YES")
        print(*t)
        return
print("NO")

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

mp = [[] for i in range(64)]

def getmp(a, b, t):
    return mp[a + b*4 + t*16]

for i in range(4):
    for j in range(4):
        mp[(i | j) + (i & j) * 4 + i*16].append(j)

var = [0]

while len(var) > 0 and len(var) < n:
    vv = var[-1]
    i = len(var) - 1
    p = getmp(a[i], b[i], vv)
    if len(p) == 0:
        appd = True
        while len(var) > 1 and appd:
            vv = var[-1]
            del var[-1]
            i = len(var) - 1
            p = getmp(a[i], b[i], var[-1])
            for t in p:
                if vv < t:
                    p.append(t)
                    appd = False
                    break

        if len(var) == 1:
            if var[0] == 3:
                var = []
            else:
                var[0] += 1
    else:
        var.append(p[0])

if len(var) > 0:
    print('YES')
    print(' '.join(map(str, var)))
else:
    print('NO')


n = int(input())
flag = 0
argsa = list(map(int, input().split()))
argsb = list(map(int, input().split()))
argst = [0]
for i in range (n-1):
    for j in range (4):
        if (argst[i] & j == argsb[i]) and (argst[i] | j == argsa[i]):
            argst.append(j)
            flag = 1
            break
    if not(flag):
        flag = 2
        break
    flag = 0
if flag == 2:
    flag = 0
    argst = []
    argst.append(1)
    for i in range(n - 1):
        for j in range(4):
            if (argst[i] & j == argsb[i]) and (argst[i] | j == argsa[i]):
                argst.append(j)
                flag = 1
                break
        if not(flag):
            flag = 2
            break
        flag = 0
if flag == 2:
    flag = 0
    argst = [2]
    for i in range(n - 1):
        for j in range(4):
            if (argst[i] & j == argsb[i]) and (argst[i] | j == argsa[i]):
                argst.append(j)
                flag = 1
                break
        if not(flag):
            flag = 2
            break
        flag = 0
if flag == 2:
    flag = 0
    argst = [3]
    for i in range(n - 1):
        for j in range(4):
            if (argst[i] & j == argsb[i]) and (argst[i] | j == argsa[i]):
                argst.append(j)
                flag = 1
                break
        if not(flag):
            flag = 2
            break
        flag = 0

if not(flag == 2):
    print('YES',end='\n')
    print(*argst)
else:
    print('NO')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


if a[0] >= b[0]:
    for x in range(4):
        for y in range(4):
            if (x | y) == a[0] and (x & y) == b[0]:
                t = [x, y]
                ans = 1
                for i in range(1, n - 1):
                    if a[i] >= b[i]:
                        flag = 0
                        for ti in range(4):
                            if (t[i] | ti == a[i]) and (t[i] & ti) == b[i]:
                                t.append(ti)
                                flag = 1
                        if flag == 0:
                            ans = 0
                            break
                    else:
                        ans = 0
                        break
                        
                if ans == 1:
                    print('YES')
                    print(*t)
                    return
    print('NO')


else:
    print('NO')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def yes(t):
    nonlocal n, a, b
    if len(t) < n:
        return False
    for i in range(n - 1):
        if t[i]|t[i + 1] == a[i] and t[i]&t[i + 1] == b[i]:
            continue
        else:
            return False
    return True

ans = []
for i in range(4):
    x = [i]
    for j in range(n - 1):
        for k in range(4):
            if x[-1]|k == a[j] and x[-1]&k == b[j]:
                x.append(k)
                break
    if yes(x):
        ans = x
if ans:
    print('YES')
    print(*ans)
else:
    print('NO')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lst = [[[(0, 0)], [], [], []], [[(0, 1), (1, 0)], [(1, 1)], [], []], [[(0, 2), (2, 0)], [], [(2, 2)], []], [[(0, 3), (1, 2), (2, 1), (3, 0)], [(1, 3), (3, 1)], [(2, 3), (3, 2)], [(3, 3)]]]
ans = []

prev = [0, 1, 2, 3]
res = []
for i in range(n - 1):
    if len(lst[a[i]][b[i]]) != 0:
        ans.append(lst[a[i]][b[i]])
    else:
        print("NO")
        return
    prev2 = []
    res.append([])
    for j in prev:
        for x in ans[-1]:
            if x[0] == j:
                prev2.append(x[1])
                res[-1].append((x[1], x[0]))
    prev = prev2

    if len(prev) == 0:
        print("NO")
        return

ans = [res[-1][0][0]]
prev = res[-1][0][1]
for i in range(len(res) - 2, -1, -1):

    for j in range(len(res[i])):
        if res[i][j][0] == prev:
            ans.append(res[i][j][0])
            prev = res[i][j][1]
            break
ans.append(prev)
ans.reverse()
print("YES")
print(*ans)

# coding=utf-8

n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

c = [[[[0, 0]], [], [], []], [[[0, 1], [1, 0]], [[1, 1]], [], []], [[[0, 2], [2, 0]], [], [[2, 2]], []], [[[0, 3], [1, 2], [2, 1], [3, 0]], [[1, 3], [3, 1]], [[2, 3], [3, 2]], [[3, 3]]]]

stack = c[a[0]][b[0]][:]

i = 1

while i < n - 1 and stack:
    helper = c[a[i]][b[i]][:]
    for e in helper:
        j = 0
        while j < len(stack):
            if stack[j][-1] == e[0] and len(stack[j]) == i + 1:
                stack[j].append(e[1])
            j += 1

    j = 0
    while j < len(stack):
        if len(stack[j]) == i + 1:
            del stack[j]
        else:
            j += 1
    i += 1

if stack:
    print('YES')
    print(*stack[0])
else:
    print('NO')


from itertools import product
#def loop(n, t=[]):
    #if n == 1:
        #return True, t
    #for i in range(3):
        #l = loop(n - 1, t + [i])
        #if l[0]:
            #for j in range(n - 1):
                #if not (t[j] | t[j + 1] == a[j] and t[j] & t[j + 1] == b[j]):
                    #break
            
            #else:            
                #return True, l[1]
    #return False, []

def next(p, o, a):
    for i in range(4):
        if (p | i == o and p & i == a):
            return i

def check(t):
    for j in range(n - 1):
        if not (t[j] | t[j + 1] == a[j] and t[j] & t[j + 1] == b[j]):
            return False
    return True

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
#print(loop(n))
#for i in product(*['0123' for i in range(n)]):
    #if check([int(j) for j in i]):
        #print('YES')
        #print(' '.join(i))
        #break
#else:
    #print('NO')
for j in range(4):
    t = [j]
    for i in range(1, n):
        nxt = next(t[-1], a[i-1], b[i-1])
        if nxt is None:
            break
        t.append(nxt)
    else:
        print('YES')
        print(' '.join(str(i) for i in t))
        break
else:
    print('NO')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = [[-1] * n for i in range(4)]
t[0][0] = 0
t[1][0] = 1
t[2][0] = 2
t[3][0] = 3
for i in range(1, n):
    for j in range(4):
        if t[j][i - 1] != -1:
            for k in range(4):
                if (t[j][i - 1] & k == b[i - 1]) and (t[j][i - 1] | k == a[i - 1]):
                    t[j][i] = k
                    break

for j in range(4):
    if t[j][n - 1] != -1:
        print("YES")
        print(*t[j])
        break
else:
    print("NO")

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
matr = [[(), (), (), ()], [(), (), (), ()], [(), (), (), ()], [(), (), (), ()]]
matr[0][0] = (0, 0)
matr[0][1] = (-1, -1)
matr[0][2] = (-1, -1)
matr[0][3] = (-1, -1)
matr[1][0] = (1, 0)
matr[1][1] = (1, 1)
matr[1][2] = (-1, -1)
matr[1][3] = (-1, -1)
matr[2][0] = (2, 0)
matr[2][1] = (-1, -1)
matr[2][2] = (2, 2)
matr[2][3] = (-1, -1)
matr[3][1] = (1, 3)
matr[3][2] = (3, 2)
matr[3][3] = (3, 3)
t = []
if (a[0] != 3 or b[0] != 0) and matr[a[0]][b[0]][0] == -1:
    print('NO')
    return
else:
    if a[0] == 3 and b[0] == 0:
        t.append(3)
        t.append(0)
        f = False
        for i in range(1, n - 1):
            if a[i] == 3 and b[i] == 0:
                if t[i] == 0:
                    t.append(3)
                elif t[i] == 1:
                    t.append(2)
                elif t[i] == 2:
                    t.append(1)
                else:
                    t.append(0)
            elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                f = True
                break
            else:
                if matr[a[i]][b[i]][0] == t[i]:
                    t.append(matr[a[i]][b[i]][1])
                else:
                    t.append(matr[a[i]][b[i]][0])
        if not f:
            print('YES')
            print(*t)
        else:
            t = []
            t.append(0)
            t.append(3)
            f = False
            for i in range(1, n - 1):
                if a[i] == 3 and b[i] == 0:
                    if t[i] == 0:
                        t.append(3)
                    elif t[i] == 1:
                        t.append(2)
                    elif t[i] == 2:
                        t.append(1)
                    else:
                        t.append(0)
                elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                    f = True
                    break
                else:
                    if matr[a[i]][b[i]][0] == t[i]:
                        t.append(matr[a[i]][b[i]][1])
                    else:
                        t.append(matr[a[i]][b[i]][0])
            if not f:
                print('YES')
                print(*t)
            else:
                t = []
                t.append(1)
                t.append(2)
                f = False
                for i in range(1, n - 1):
                    if a[i] == 3 and b[i] == 0:
                        if t[i] == 0:
                            t.append(3)
                        elif t[i] == 1:
                            t.append(2)
                        elif t[i] == 2:
                            t.append(1)
                        else:
                            t.append(0)
                    elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                        f = True
                        break
                    else:
                        if matr[a[i]][b[i]][0] == t[i]:
                            t.append(matr[a[i]][b[i]][1])
                        else:
                            t.append(matr[a[i]][b[i]][0])
                if not f:
                    print('YES')
                    print(*t)
                else:
                    t = []
                    t.append(2)
                    t.append(1)
                    f = False
                    for i in range(1, n - 1):
                        if a[i] == 3 and b[i] == 0:
                            if t[i] == 0:
                                t.append(3)
                            elif t[i] == 1:
                                t.append(2)
                            elif t[i] == 2:
                                t.append(1)
                            else:
                                t.append(0)
                        elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                            f = True
                            break
                        else:
                            if matr[a[i]][b[i]][0] == t[i]:
                                t.append(matr[a[i]][b[i]][1])
                            else:
                                t.append(matr[a[i]][b[i]][0])
                    if not f:
                        print('YES')
                        print(*t)
                    else:
                        print('NO')
    else:
        t.append(matr[a[0]][b[0]][0])
        t.append(matr[a[0]][b[0]][1])
        f = False
        for i in range(1, n - 1):
            if a[i] == 3 and b[i] == 0:
                if t[i] == 0:
                    t.append(3)
                elif t[i] == 1:
                    t.append(2)
                elif t[i] == 2:
                    t.append(1)
                else:
                    t.append(0)
            elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                f = True
                break
            else:
                if matr[a[i]][b[i]][0] == t[i]:
                    t.append(matr[a[i]][b[i]][1])
                else:
                    t.append(matr[a[i]][b[i]][0])
        if not f:
            print('YES')
            print(*t)
        else:
            t = []
            t.append(matr[a[0]][b[0]][1])
            t.append(matr[a[0]][b[0]][0])
            f = False
            for i in range(1, n - 1):
                if a[i] == 3 and b[i] == 0:
                    if t[i] == 0:
                        t.append(3)
                    elif t[i] == 1:
                        t.append(2)
                    elif t[i] == 2:
                        t.append(1)
                    else:
                        t.append(0)
                elif matr[a[i]][b[i]][0] != t[i] and matr[a[i]][b[i]][1] != t[i]:
                    f = True
                    break
                else:
                    if matr[a[i]][b[i]][0] == t[i]:
                        t.append(matr[a[i]][b[i]][1])
                    else:
                        t.append(matr[a[i]][b[i]][0])
            if not f:
                print('YES')
                print(*t)
            else:
                print('NO')


n = int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
ways = {(0,0): [(0,0)], (1,0):[(0,1),(1,0)], (1,1):[(1,1)], (2,0):[(2,0),(0,2)], (2,2):[(2,2)], (3,0):[(3,0),(0,3),(2,1),(1,2)],(3,1):[(3,1),(1,3)],(3,2):[(3,2),(2,3)], (3,3):[(3,3)]}
ans = []
ddl = []
s= {0,1,2,3}
for i in range(n-2,-1,-1):
    if (a[i],b[i]) not in ways:
        print("NO")
        return
    d = ways[(a[i],b[i])]
    ns = set()
    dd = {None: None}
    for st, en in d:
        if (en in s):
            ns.add(st)
            dd[st] = en
    if i == 0:
        if len(ns) == 0:
            print("NO")
            return
        k = ns.pop()
        ans = [k, dd[k]]
    else:
        ddl.append(dd)
    s = ns
        
for i in range(1,n-1):
    dd = ddl.pop()
    ans.append(dd[ans[-1]])



if ans[0] == None:
    print('NO')
else:
    print('YES')
    print(' '.join(map(str,ans)))


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
trr = [0 for i in range(n)]
for j in range(4):
    trr[0] = j
    fl = True
    for i in range(n - 1):
        if arr[i] == brr[i]:
            if trr[i] != arr[i]:
                fl = False
                break
            trr[i + 1] = arr[i]
        else:
            if brr[i] == 3:
                fl = False
                break
            if brr[i] == 2:
                if arr[i] == 3:
                    if trr[i] == 2:
                        trr[i + 1] = 3
                    elif trr[i] == 3:
                        trr[i + 1] = 2
                    else:
                        fl = False
                        break
                else:
                    fl = False
                    break
            if brr[i] == 1:
                if arr[i] == 3:
                    if trr[i] == 1:
                        trr[i + 1] = 3
                    elif trr[i] == 3:
                        trr[i + 1] = 1
                    else:
                        fl = False
                        break
                else:
                    fl = False
                    break        
            if brr[i] == 0:
                if arr[i] == 1:
                    if trr[i] == 0:
                        trr[i + 1] = 1
                    elif trr[i] == 1:
                        trr[i + 1] = 0
                    else:
                        fl = False
                        break
                elif arr[i] == 2:
                    if trr[i] == 2:
                        trr[i + 1] = 0
                    elif trr[i] == 0:
                        trr[i + 1] = 2
                    else:
                        fl = False
                        break         
                else:
                    if trr[i] == 1:
                        trr[i + 1] = 2
                    elif trr[i] == 2:
                        trr[i + 1] = 1
                    elif trr[i] == 3:
                        trr[i + 1] = 0
                    else:
                        trr[i + 1] = 3

    #print(trr)
    if fl:
        print('YES')
        print(*trr)
        break
else:
    print('NO')



size : int = int(input())

seq1 = []
seq2 = []

for i in input().split(" "):
    seq1.append(int(i))

for i in input().split(" "):
    seq2.append(int(i))

out = []
for i in range(0, size):
    out.append(-1)

for tFirst in range( 0, 4 ):
    out[0] = tFirst
    for i in range(0, size - 1):
        for t2 in range( 0, 4 ):
            if out[i] | t2 == seq1[i] and out[i] & t2 == seq2[i]:
                out[i+1] = t2


    if -1 not in out:
        print("YES")
        for i in out:
            print(i, end = " ")

        return

if -1 in out:
    print("NO")

from functools import reduce

n = int(input())
a,b = (list(map(int, input().split())) for _ in (None, None))
oq=set(range(4))
q=oq.copy()
w=[]
possible=True
for i in range(n-1):
    p=set()
    w.append({})
    for t1 in q:
        e=set([t2 for t2 in oq if t2|t1==a[i] and t2&t1==b[i]])
        p|=e
        w[i][t1]=e
    q=p
    if len(q)==0:
        possible=False
        break

print('YES' if possible else 'NO')
if possible:
    y=None
    for l in q:
        y=l
        break
    path=[y]
    for g in reversed(w):
        for k, u in list(g.items()):
            if y in u:
                y=k
                break
        path.append(y)
    print(reduce(lambda x,y:x+' '+str(y), reversed(path), '')[1:])



n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(4):
    ans=[-1]*n
    ans[0]=i
    flag=False
    for j in range(1,n):
        flag=False
        for k in range(4):
            if a[j-1]==(k|ans[j-1]) and b[j-1]==(k&ans[j-1]):
                ans[j]=k
                flag=True
        if not flag:
            break
    if flag:
        print("YES")
        print(*ans)
        return
print("NO")

n = int(input())

lst1 = [int(x) for x in input().split()]
lst2 = [int(x) for x in input().split()]

F = False
for x in range(4):
    ans = [-1] * n
    ans[0] = x
    for y in range(1, n):
        f = False
        for z in range(4):
            if z | ans[y - 1] == lst1[y - 1] and z & ans[y - 1] == lst2[y - 1]:
                ans[y] = z
                f = True
                break
        if not f:
            break
        
    if f:
        F = True
        break

if F:
    print("YES")
    print(*ans)
else:
    print("NO")


import sys

def minp():
	return sys.stdin.readline().strip()
def mint():
	return int(minp())
def mints():
	return map(int,minp().split())

kk = [[[None]*4 for i in range(4)] for j in range(4)]
for i in range(4):
	for j in range(4):
		for k in range(4):
			z = None
			for x in range(4):
				if (i|x == j) and (i&x == k):
					z = x
			kk[i][j][k] = z

n = mint()
a = list(mints())
b = list(mints())
t = [0]*n
for i in range(4):
	t[0] = i
	ok = True
	for j in range(n-1):
		t[j+1] = kk[t[j]][a[j]][b[j]]
		if t[j+1] == None:
			ok = False
			break
	if ok:
		print("YES")
		print(*t)
		return
print("NO")

def my(a, b, c):
    for x, y in zip(a, b):
        for z in range(4):
            if c[-1] | z == x and c[-1] & z == y:
                c += [z]
                break
        else:
            return []
    return c

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

for i in range(4):
    t = my(a, b, [i])
    if t:
        print('YES')
        print(*t)
        break
else:
    print('NO')        


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(n-1):
    if a[i] == 3:
        a[i] = '11'
    elif a[i] == 2:
        a[i] = '10'
    elif a[i] == 1:
        a[i] = '01'
    elif a[i] == 0:
        a[i] = '00'

for i in range(n-1):
    if b[i] == 3:
        b[i] = '11'
    elif b[i] == 2:
        b[i] = '10'
    elif b[i] == 1:
        b[i] = '01'
    elif b[i] == 0:
        b[i] = '00'


def Checker(z, x, y):
    if z == '0':
        if x == '0' and y == '0':
            return '0'
        elif x == '0' and y == '1':
            return None
        elif x == '1' and y == '0':
            return '1'
        elif x == '1' and y == '1':
            return None
    elif z == '1':
        if x == '0' and y == '0':
            return None
        elif x == '0' and y == '1':
            return None
        elif x == '1' and y == '0':
            return '0'
        elif x == '1' and y == '1':
            return '1'


s = []
flag = True

for ti in ['00', '01', '10', '11']:
    t = ti
    if len(s) == n:
        break
    elif (Checker(t[0], a[0][0], b[0][0]) is not None) and (Checker(t[1], a[0][1], b[0][1]) is not None):
        s.append(t)
        for i in range(n-1):
            c = Checker(t[0], a[i][0], b[i][0])
            e = Checker(t[1], a[i][1], b[i][1])
            if (c is not None) and (e is not None):
                k = ''.join([c, e])
                s.append(k)
                t = k
            else:
                s.clear()
                break
    elif t == '11':
        flag = False
if flag and s:
    print('YES')
    for i in range(n):
        if s[i] == '11':
            print(3, end=' ')
        elif s[i] == '10':
            print(2, end=' ')
        elif s[i] == '01':
            print(1, end=' ')
        elif s[i] == '00':
            print(0, end=' ')
else:
    print('NO')