Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not three.

So they play with each other according to following rules:  Alex and Bob play the first game, and Carl is spectating;  When the game ends, the one who lost the game becomes the spectator in the next game, and the one who was spectating plays against the winner. 

Alex, Bob and Carl play in such a way that there are no draws.

Today they have played n games, and for each of these games they remember who was the winner. They decided to make up a log of games describing who won each game. But now they doubt if the information in the log is correct, and they want to know if the situation described in the log they made up was possible (that is, no game is won by someone who is spectating if Alex, Bob and Carl play according to the rules). Help them to check it!


-----Input-----

The first line contains one integer n (1 ≤ n ≤ 100) — the number of games Alex, Bob and Carl played.

Then n lines follow, describing the game log. i-th line contains one integer a_{i} (1 ≤ a_{i} ≤ 3) which is equal to 1 if Alex won i-th game, to 2 if Bob won i-th game and 3 if Carl won i-th game.


-----Output-----

Print YES if the situation described in the log was possible. Otherwise print NO.


-----Examples-----
Input
3
1
1
2

Output
YES

Input
2
1
2

Output
NO



-----Note-----

In the first example the possible situation is:  Alex wins, Carl starts playing instead of Bob;  Alex wins, Bob replaces Carl;  Bob wins. 

The situation in the second example is impossible because Bob loses the first game, so he cannot win the second one.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
__author__ = 'NIORLYS'
n = int(input())
spectating = 3
a = []
log_is_possible = 1
while n:
	a.append(int(input()))
	n -= 1
for winner in a:
	if winner != spectating:
		spectating = 6 - winner - spectating
	else:
		log_is_possible = 0
		break
if log_is_possible:
	print('YES')
else:
	print('NO')


num = input()
inGame = [1, 2]
check = 1
for _ in range(int(num)):
	x = int(input())
	nextNum = 6 - (inGame[0] + inGame[1])
	if x == int(inGame[0]):
		inGame[1] = nextNum
		continue
	elif x == inGame[1]:
		inGame[0] = nextNum
		continue
	else:
		check = 0
		break
if check == 1:
	print('YES')
else:
	print('NO')


def solve():
	n = int(input())
	l = [int(input()) for _ in range(n)]
	s = [1, 2]
	wa = 3
	for i in l:
		if not i in s:
			print('NO')
			return
		lose = wa - i
		new = 6 - wa
		wa = i + new
		s = [i, new]
	print('YES')
solve()


s = 3
for _ in range(int(input())):
	i = int(input())
	if i == s:
		print('NO')
		break
	for x in range(1, 4):
		if x != s and x != i:
			s = x
			break
else:
	print('YES')


import sys
n = int(input())
for i in range(n):
	if i == 0:
		winner = 1
		looser = 2
		looker = 3
		a = int(input())
		if a == 3:
			print('NO')
			return
		if a == 1:
			(looser, looker) = (looker, looser)
		else:
			(winner, looker) = (looker, winner)
		continue
	a = int(input())
	if a == looker:
		print('NO')
		return
	if a == winner:
		(looser, looker) = (looker, looser)
	else:
		(winner, looker) = (looker, winner)
print('YES')


n = int(input())

def chess(n):
	S = 'C'
	for i in range(n):
		g = int(input())
		if g == 1 and S == 'C':
			S = 'B'
		elif g == 1 and S == 'B':
			S = 'C'
		elif g == 2 and S == 'A':
			S = 'C'
		elif g == 2 and S == 'C':
			S = 'A'
		elif g == 3 and S == 'A':
			S = 'B'
		elif g == 3 and S == 'B':
			S = 'A'
		else:
			return 'NO'
	return 'YES'
print(chess(n))


n = int(input())
is_ok = True
order = [False, True, True, False]
while n:
	win = int(input())
	if is_ok:
		if not order[win]:
			is_ok = False
		else:
			for i in range(1, 4):
				if order[i]:
					if i != win:
						order[i] = False
				else:
					order[i] = True
	n -= 1
print('YES' if is_ok else 'NO')


n = int(input())
a = []
curr = 3
flag = 0
for i in range(n):
	a.append(int(input()))
for i in range(n):
	if a[i] == curr:
		flag = 1
		break
	elif a[i] == 1:
		if curr == 2:
			curr = 3
		else:
			curr = 2
	elif a[i] == 2:
		if curr == 1:
			curr = 3
		else:
			curr = 1
	elif curr == 2:
		curr = 1
	else:
		curr = 2
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
k = []
f = True
for x in range(n):
	k.append(int(input()))
tn = 3
for i in range(n):
	v = k[i]
	if v == tn:
		f = False
	tn = 6 - v - tn
if f is True:
	print('YES')
else:
	print('NO')


t = int(input())
c = [1, 2]
for _ in range(t):
	p = int(input())
	if p == c[0]:
		if p == 1 and c[1] == 2:
			c[1] = 3
		elif p == 1 and c[1] == 3:
			c[1] = 2
		elif p == 2 and c[1] == 3:
			c[1] = 1
		elif p == 2 and c[1] == 1:
			c[1] = 3
		elif p == 3 and c[1] == 1:
			c[1] = 2
		elif p == 3 and c[1] == 2:
			c[1] = 1
	elif p == c[1]:
		if p == 1 and c[0] == 2:
			c[0] = 3
		elif p == 1 and c[0] == 3:
			c[0] = 2
		elif p == 2 and c[0] == 3:
			c[0] = 1
		elif p == 2 and c[0] == 1:
			c[0] = 3
		elif p == 3 and c[0] == 1:
			c[0] = 2
		elif p == 3 and c[0] == 2:
			c[0] = 1
	else:
		print('NO')
		exit()
print('YES')


import sys
n = int(input())
s = '12'
t = [1, 2, 3]
l = [1, 1, 0]
for i in range(n):
	k = int(input())
	if k == 1:
		if l[0] == 0:
			print('NO')
			sys.exit()
		l[0] = 1
		if l[1] == 1:
			l[2] = 1
			l[1] = 0
		else:
			l[2] = 0
			l[1] = 1
	elif k == 2:
		if l[1] != 1:
			print('NO')
			sys.exit()
		if l[0] == 1:
			l[2] = 1
			l[0] = 0
		else:
			l[2] = 0
			l[0] = 1
	else:
		if l[2] != 1:
			print('NO')
			sys.exit()
		if l[0] == 1:
			l[0] = 0
			l[1] = 1
		else:
			l[0] = 1
			l[1] = 0
print('YES')


n = int(input())
T = set([1, 2])
p = 0
for i in range(n):
	a = int(input())
	if a in T:
		p = p + 1
	else:
		print('NO')
		break
	for i in range(1, 4):
		if i not in T:
			m = i
			break
	for k in T:
		if k != a:
			T.remove(k)
			T.add(m)
			break
if p == n:
	print('YES')
else:
	pass


n = int(input())
spec = 3
player1 = 1
player2 = 2
f = True
for i in range(n):
	d = int(input())
	if d != player1 and d != player2:
		print('NO')
		f = False
		break
	elif d == player1:
		(player2, spec) = (spec, player2)
	elif d == player2:
		(player1, spec) = (spec, player1)
if f:
	print('YES')


n = 3
tf = True
for i in range(int(input())):
	a = int(input())
	if a != n:
		arr = [1, 2, 3]
		arr.pop(arr.index(a))
		arr.pop(arr.index(n))
		n = arr[0]
	else:
		print('NO')
		exit()
print('YES')


def aaa():
	n = int(input())
	cc = 3
	mm = {1: {2: 3, 3: 2}, 2: {1: 3, 3: 1}, 3: {1: 2, 2: 1}}
	for _ in range(n):
		a = int(input())
		if a == cc:
			return 'NO'
		cc = mm[a][cc]
	return 'YES'
ans = aaa()
print(ans)


n = int(input())
players = [1, 2]
nub = 3
for i in range(n):
	a = int(input())
	if a in players:
		if players[0] == a:
			b = nub
			nub = players[1]
			players = [a, b]
		else:
			b = nub
			nub = players[0]
			players = [a, b]
	else:
		print('NO')
		break
else:
	print('YES')


import sys
sys.setrecursionlimit(100000000)
N = int(input())
arr = [True, True, False]
state = True
for i in range(N):
	log = int(input())
	if arr[log - 1]:
		arr[log - 1] = False
		lose = 0
		for j in range(3):
			if arr[j]:
				lose = j
		for j in range(3):
			arr[j] = True
		arr[lose] = False
	else:
		state = False
if state:
	print('YES')
else:
	print('NO')


IL = lambda : list(map(int, input().split()))
I = lambda : int(input())
n = I()
pl = [1, 2]
ans = True
for i in range(n):
	w = I()
	if w not in pl:
		ans = False
	pl = [w] + [j for j in range(1, 4) if j not in pl]
print('YES' if ans else 'NO')


l = [int(input()) for _ in range(int(input()))]
p = {1, 2}
for e in l:
	if e in p:
		p = {1, 2, 3} - p | {e}
	else:
		print('NO')
		return
print('YES')


n = int(input())
oraTinJon = 3
for i in range(n):
	keKeKhelche = int(input())
	if keKeKhelche == oraTinJon:
		print('NO')
		exit()
	oraTinJon = 6 - oraTinJon - keKeKhelche
print('YES')


n = int(input())
nab = 3
u1 = 1
u2 = 2
res = True
for i in range(n):
	p = int(input())
	if nab != p:
		l = nab
		nab = u1 + u2 - p
		u1 = p
		u2 = l
	else:
		res = False
if res:
	print('YES')
else:
	print('NO')


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():
	n = int(input())
	winner = 0
	sp = 3
	loser = 0
	ans = 'YES'
	for i in range(n):
		take = int(input())
		if take == sp:
			ans = 'NO'
			break
		else:
			winner = take
			if winner == 1 and sp == 2:
				sp = 3
			elif winner == 1 and sp == 3:
				sp = 2
			elif winner == 2 and sp == 3:
				sp = 1
			elif winner == 2 and sp == 1:
				sp = 3
			elif winner == 3 and sp == 1:
				sp = 2
			else:
				sp = 1
	print(ans)
main()


n = int(input())
(a, b, c) = (1, 2, 3)
for i in range(n):
	x = int(input())
	if x == a:
		(b, c) = (c, b)
	elif x == b:
		(a, b, c) = (b, c, a)
	elif x == c:
		print('NO')
		exit(0)
print('YES')


n = int(input())
a = [1, 2]
b = 3
k = 0
for i in range(n):
	x = int(input())
	if b == x:
		print('NO')
		break
	else:
		if a[0] == x:
			(b, a[1]) = (a[1], b)
		else:
			(b, a[0]) = (a[0], b)
		k += 1
if k == n:
	print('YES')


n = int(input())
spectating = 3
for i in range(0, n):
	a = int(input())
	if a == spectating:
		print('NO')
		exit()
	for j in range(1, 4):
		if j != a and j != spectating:
			spectating = j
			break
print('YES')


q = [1, 1, 0]
for i in range(int(input())):
	a = int(input())
	if not q[a - 1]:
		print('NO')
		break
	else:
		for j in range(3):
			if a - 1 != j:
				q[j] = not q[j]
else:
	print('YES')


num = int(input())
spectator = 3
p1 = 1
p2 = 2
yes = True
for i in range(0, num):
	winner = int(input())
	if winner is spectator:
		print('NO')
		yes = False
		break
	if p1 is winner:
		temp = spectator
		spectator = p2
		p2 = temp
	else:
		temp = spectator
		spectator = p1
		p1 = temp
if yes:
	print('YES')


players = [1, 2]
n = int(input())
curr_good = True
for i in range(n):
	winner = int(input())
	if winner not in players:
		curr_good = False
	players = [6 - (players[0] + players[1]), winner]
print('YES' if curr_good else 'NO')


count = int(input())
games = []
for x in range(count):
	games.append(int(input()))
state = 'YES'
play = [1, 2]
for x in games:
	if x in play:
		play = [x, 6 - (play[0] + play[1])]
	else:
		state = 'NO'
		break
print(state)


n = int(input())
players = [1, 2]
ans = 'YES'
for case in range(n):
	a = int(input())
	if a not in players:
		ans = 'NO'
		break
	else:
		players = [6 - sum(players), a]
print(ans)


(n, first, second, observer, res) = (int(input()), 1, 2, 3, 'NO')
for i in range(n):
	winner = int(input())
	if winner == observer:
		break
	(first, second) = (winner, observer)
	observer = 6 - (winner + observer)
else:
	res = 'YES'
print(res)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
spectator = 3
can = True
for winner in a:
	if winner == spectator:
		can = False
	if spectator == 1:
		if winner == 2:
			spectator = 3
		else:
			spectator = 2
	elif spectator == 2:
		if winner == 1:
			spectator = 3
		else:
			spectator = 1
	elif winner == 1:
		spectator = 2
	else:
		spectator = 1
if can:
	print('YES')
else:
	print('NO')


n = int(input())
d = [1, 2]
s = [3]
t = 0
for i in range(n):
	a = int(input())
	if i % 2 == 0:
		if a in d:
			s.append(a)
			d.remove(a)
		else:
			t += 1
	elif a in s:
		d.append(a)
		s.remove(a)
	else:
		t += 1
if t > 0:
	print('NO')
else:
	print('YES')


n = int(input())
a = [1, 2]
f = 'YES'
for i in range(n):
	x = int(input())
	if x in a:
		a = [x, 6 - sum(a)]
	else:
		f = 'NO'
print(f)


n = int(input())
c = 3
ans = True
for i in range(n):
	w = int(input())
	if c == w:
		ans = False
	c = 6 - c - w
print('YES' if ans else 'NO')


(x, y) = (1, 2)
z = 3
for i in range(int(input())):
	a = int(input())
	if a == x:
		k = y
		y = z
		z = k
		continue
	elif a == y:
		k = x
		x = z
		z = k
		continue
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
spec = 3
all = [1, 2, 3]
for i in range(n):
	num = int(input())
	if num == spec:
		print('NO')
		exit(0)
	else:
		all.remove(spec)
		all.remove(num)
		spec = all[0]
		all = [1, 2, 3]
print('YES')


n = int(input())
g = list()
for i in range(0, n):
	g.append(int(input()))
w = None
s = 3
inter = False
for w in g:
	if w == s:
		print('NO')
		inter = True
		break
	s = 6 - w - s
if not inter:
	print('YES')


def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
n = int(input())
(a, b, c) = (1, 2, 3)
for i in range(n):
	winner = int(input())
	if winner not in [a, b]:
		print('NO')
		exit(0)
	a = winner
	b = c
	c = 6 - (a + b)
print('YES')


n = input()
player1 = 1
player2 = 2
spec = 3
list = []
for x in range(int(n)):
	winner = int(input())
	if winner == spec:
		print('NO')
		exit()
	elif winner == player1:
		temp = player2
		player2 = spec
		spec = temp
	else:
		temp = player1
		player1 = spec
		spec = temp
	continue
print('YES')


games = int(input())
x = 1
y = 2
correct = True
for rpt in range(games):
	winner = int(input())
	if x == winner:
		for i in [1, 2, 3]:
			if i != x and i != y:
				y = i
				break
	elif y == winner:
		for i in [1, 2, 3]:
			if i != x and i != y:
				x = i
				break
	else:
		correct = False
if correct == True:
	print('YES')
else:
	print('NO')


N = int(input())
play = {1, 2}
for i in range(N):
	winner = int(input())
	if winner not in play:
		print('NO')
		break
	loser = list(play - {winner})[0]
	other = list({1, 2, 3} - {winner, loser})[0]
	play.remove(loser)
	play.add(other)
else:
	print('YES')


n = int(input())
g = []
flag = False
for i in range(n):
	g.append(int(input()))
nab = 3
for i in range(n):
	if g[i] == nab:
		flag = True
		print('NO')
		break
	nab = 1 + 2 + 3 - g[i] - nab
if flag == False:
	print('YES')


n = int(input())
c = 3
for i in range(n):
	a = int(input())
	if a == c:
		print('NO')
		exit()
	c = 6 - a - c
else:
	print('YES')


n = int(input())
playing_n = [1, 2]
spec = 3
for i in range(n):
	now = int(input())
	if now == spec:
		print('NO')
		exit(0)
	if playing_n[0] == now:
		tmp = spec
		spec = playing_n[1]
		playing_n[1] = tmp
	else:
		tmp = spec
		spec = playing_n[0]
		playing_n[0] = tmp
print('YES')


n = int(input())
spec = 3
err = 0
for i in range(n):
	win = int(input())
	if err == 0:
		if spec == 3:
			if win == 1:
				spec = 2
			elif win == 2:
				spec = 1
			else:
				print('NO')
				err = 1
		elif spec == 2:
			if win == 1:
				spec = 3
			elif win == 3:
				spec = 1
			else:
				print('NO')
				err = 1
		elif spec == 1:
			if win == 3:
				spec = 2
			elif win == 2:
				spec = 3
			else:
				print('NO')
				err = 1
		else:
			print('NO')
			err = 1
if err == 0:
	print('YES')


people = set('123')
players = set('12')
for _ in range(int(input())):
	winner = input()
	if winner not in players:
		print('NO')
		break
	players = {winner} | people - players
else:
	print('YES')


def otherpl(a, b):
	k = [1, 2, 3]
	k.remove(a)
	k.remove(b)
	return int(k[0])
n = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
count = 0
x = 3
for i in range(len(a)):
	if a[i] == x:
		print('NO')
		break
	else:
		count += 1
	x = otherpl(a[i], x)
if count == len(a):
	print('YES')


from operator import itemgetter
n = int(input())
ai = [0] * 4
ai[1] = 1
ai[2] = 1
ans = 'YES'
for i in range(n):
	num = int(input())
	if ai[num] == 0:
		ans = 'NO'
		break
	for j in range(4):
		ai[j] = 1 - ai[j]
	ai[num] = 1
print(ans)


n = int(input())
spectator = 3
for _ in range(n):
	cur = int(input())
	if cur == spectator:
		print('NO')
		break
	spectator = {1, 2, 3}.difference({spectator, cur}).pop()
else:
	print('YES')


n = int(input())
c = 3
for x in range(n):
	p = int(input())
	if p == c:
		print('NO')
		exit()
	c = 6 - c - p
print('YES')


s = 3
t = []
u = 0
for i in range(int(input())):
	a = int(input())
	t.append(a)
for k in range(len(t)):
	if t[k] != s:
		pass
		s = 6 - (t[k] + s)
	else:
		print('NO')
		u += 1
		break
if u == 0:
	print('YES')


n = int(input())
players = {1: True, 2: True, 3: False}
obv = 3
res = 'YES'
for i in range(n):
	a = int(input())
	if not players[a]:
		res = 'No'
		break
	else:
		for (k, b) in players.items():
			if k != a and b:
				break
		players[obv] = True
		players[a] = True
		players[k] = False
		obv = k
print(res)


def test(W):
	s = 3
	for w in W:
		if w == s:
			return False
		s = 6 - s - w
	return True
n = int(input())
W = [int(input()) for _ in range(n)]
print('YES' if test(W) else 'NO')


n = int(input())
a = []
f = 1
b = [1, 2]
for i in range(n):
	a.append(int(input()))
for i in range(n):
	if a[i] == 1:
		if b == [1, 2]:
			b = [1, 3]
		elif b == [2, 1]:
			b = [3, 1]
		elif b == [1, 3]:
			b = [1, 2]
		elif b == [3, 1]:
			b = [2, 1]
		else:
			f = 0
			break
	if a[i] == 2:
		if b == [1, 2]:
			b = [3, 2]
		elif b == [2, 1]:
			b = [2, 3]
		elif b == [2, 3]:
			b = [2, 1]
		elif b == [3, 2]:
			b = [1, 2]
		else:
			f = 0
			break
	if a[i] == 3:
		if b == [3, 2]:
			b = [3, 1]
		elif b == [2, 3]:
			b = [1, 3]
		elif b == [1, 3]:
			b = [2, 3]
		elif b == [3, 1]:
			b = [3, 2]
		else:
			f = 0
			break
if f == 1:
	print('YES')
else:
	print('NO')


n = int(input())
consistent = True
spectator = 3
for i in range(n):
	winner = int(input())
	if winner == spectator:
		consistent = False
	spectator = 6 - spectator - winner
print('YES' if consistent else 'NO')


def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0

def nia():
	s = input()
	while len(s) == 0:
		s = input()
	s = s.split()
	iVal = []
	for i in range(len(s)):
		iVal.append(int(s[i]))
	return iVal

def solve():
	games = ni()
	winner = [None] * games
	for i in range(games):
		winner[i] = ni()
	last = winner[0]
	if last == 3:
		return False
	loser = 3 - last
	spect = 3
	for i in range(1, games):
		if winner[i] == last:
			temp = loser
			loser = spect
			spect = temp
		elif winner[i] == loser:
			return False
		else:
			spect = loser
			loser = last
			last = winner[i]
	return True
if solve():
	print('YES')
else:
	print('NO')


n = int(input())
test = True
list1 = [1, 2]
list2 = [3]
list3 = []
for i in range(n):
	temp = int(input())
	if temp not in list1:
		test = False
		break
	list3 = list2 + [temp]
	list1.remove(temp)
	list2.clear()
	(list2, list3) = (list3, list2)
	(list1, list2) = (list2, list1)
if test == False:
	print('NO')
else:
	print('YES')


n = int(input())
cur_vis = 3
for i in range(1, n + 1):
	a = int(input())
	if a == cur_vis:
		print('NO')
		exit()
	cur_vis = ({1, 2, 3} - {a, cur_vis}).pop()
print('YES')


n = int(input())
ng = 3
flag = True
for i in range(n):
	k = int(input())
	if k == ng:
		flag = False
	else:
		for j in range(1, 4):
			if j != ng and j != k:
				ng = j
				break
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
(x, y, z, ans) = (1, 2, 3, 'YES')
for i in range(n):
	k = int(input())
	if k == x:
		(x, y, z) = (x, z, y)
	elif k == y:
		(x, y, z) = (z, y, x)
	else:
		ans = 'NO'
		break
print(ans)


n = int(input())
g = []
for i in range(n):
	g.append(int(input()))
res = 'YES'
st1 = [1, 2, 3]
st2 = [0, 0, 0]
gres = []
gres.append(tuple(st1))
for i in range(n):
	d = g[i]
	st2[0] = d
	st2[1] = st1[2]
	for i in range(1, 4):
		if i != st2[0] and i != st2[1]:
			st2[2] = i
	st1 = st2
	gres.append(tuple(st2))
for i in range(len(gres) - 1):
	if gres[0][0] == 3:
		res = 'NO'
		break
	if gres[i][2] == gres[i + 1][0]:
		res = 'NO'
		break
print(res)


p = {1, 2}
for x in range(int(input())):
	n = int(input())
	if n not in p:
		print('NO')
		break
	p = {n, *{1, 2, 3}.symmetric_difference(p)}
else:
	print('YES')


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, sys.stdin))
b = [0, 1, 1, 0]
for x in a:
	if b[x] == 0:
		print('NO')
		break
	for i in range(1, 4):
		if i != x:
			b[i] ^= 1
else:
	print('YES')


players = {1, 2, 3}
not_playing = 3
cases = int(input())
trial = cases
for x in range(cases):
	winner = int(input())
	if winner == not_playing:
		print('NO')
		break
	for y in players:
		if y != winner and y != not_playing:
			not_playing = y
			break
	trial -= 1
if trial == 0:
	print('YES')


num_juegos = int(input(''))
espectador = 3
encuentro = [1, 2]
contador = 0
aux = 0
for i in range(num_juegos):
	ganador = int(input(''))
	if encuentro.count(ganador) > 0:
		contador = 1
		if encuentro[0] == ganador:
			aux = espectador
			espectador = encuentro[1]
			encuentro[1] = aux
		else:
			aux = espectador
			espectador = encuentro[0]
			encuentro[0] = aux
	else:
		contador = -1
		break
if contador == 1:
	print('Yes')
else:
	print('NO')


n = int(input())
saw = 3
winner = 0
for i in range(n):
	winner = int(input())
	if winner == saw:
		print('NO')
		exit()
	else:
		l = [1, 2, 3]
		l.remove(winner)
		l.remove(saw)
		saw = l[0]
print('YES')


a = int(input())
l = []
l1 = [1, 2, 3]
x = 0
y = 1
for i in range(a):
	l2 = int(input())
	l.append(l2)
for i in range(len(l)):
	if l[i] == l1[x]:
		d = l1[y]
		del l1[y]
		l1.append(d)
	elif l[i] == l1[y]:
		d = l1[x]
		del l1[x]
		l1.append(d)
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
a = [1, 1, 0]
i = 0
while i < n:
	b = int(input())
	i += 1
	if a[b - 1] == 0:
		print('NO')
		break
	else:
		a[b - 1] = 0
		k = 0
		while k < 3:
			if a[k] == 0:
				a[k] = 1
			else:
				a[k] = 0
			k += 1
	if i == n:
		print('YES')
		break


n = int(input())
(ind1, ind2) = (1, 2)
indicator = True
for i in range(n):
	a = int(input())
	if a != ind1 and a != ind2:
		indicator = False
		print('NO')
		break
	else:
		(ind1, ind2) = (a, 6 - (ind1 + ind2))
if indicator:
	print('YES')


n = int(input())
l = []
v = 1
v1 = 2
v2 = 3
for i in range(n):
	a = int(input())
	if v1 != a and v != a:
		print('NO')
		exit()
	elif a == v1:
		v1 = a
		(v, v2) = (v2, v)
	else:
		(v1, v2) = (v2, v1)
print('YES')


import os
import sys
from io import BytesIO, IOBase
import math
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')
n = int(input())
l = int(input())
if l == 3:
	print('NO')
else:
	if l == 1:
		c = 2
	else:
		c = 1
	f = True
	for i in range(1, n):
		no = int(input())
		if no == c:
			f = False
			break
		c = 6 - c - no
	if f:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	tot = 6
	spect = 3
	for i in range(n):
		a = int(input())
		if a == spect:
			print('NO')
			return 0
		spect = tot - (a + spect)
	print('YES')
	return 0
main()


n = int(input())
l = list()
for i in range(n):
	l.append(int(input()))
f = 0
c = True
d = [1, 2]
e = 3
j = 0
while j < n and c == True:
	h = d.count(l[j])
	if h > 0:
		f = d[1 - d.index(l[j])]
		d[1 - d.index(l[j])] = e
		e = f
		j = j + 1
	else:
		c = False
if c == True:
	print('Yes')
else:
	print('NO')


from collections import deque as de
import math
import re
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

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

def binarytodecimal(n):
	return int(n, 2)

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 get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

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

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

def si():
	return input()

def li():
	return list(map(int, input().split()))
n = int(input())
l = []
while n:
	n -= 1
	a = ii()
	l.append(a)
if l[0] == 3:
	print('NO')
else:
	if l[0] == 1:
		se = 2
		pt = 3
	else:
		se = 1
		pt = 3
	ch = 1
	for i in range(1, len(l)):
		if l[i] == se:
			ch = 0
			print('NO')
			break
		else:
			winner = l[i]
			temp = se
			pt = temp
			se = 6 - winner - pt
	if ch:
		print('YES')


def validar_partidas(n, ganadores):
	perdedor = 3
	partida = [1, 2]
	result = 0
	if ganadores[0] == 3:
		result = -1
	else:
		for j in range(len(ganadores)):
			if ganadores[j] == perdedor:
				result = -1
			elif partida.count(ganadores[j]) > 0:
				if partida[0] == ganadores[j]:
					espectador = perdedor
					perdedor = partida[1]
					partida[1] = espectador
				else:
					espectador = perdedor
					perdedor = partida[0]
					partida[0] = espectador
	if result == -1:
		print('NO')
	else:
		print('YES')
n = int(input(''))
ganadores = list()
for i in range(n):
	ganadores.append(int(input('')))
validar_partidas(n, ganadores)


n = int(input())
l = [1, 2]
flag = 1
z = [1, 2, 3]
for i in range(n):
	t = int(input())
	if t in l:
		z.remove(t)
		if z[0] in l:
			l.remove(z[0])
			z.remove(z[0])
		elif z[1] in l:
			l.remove(z[1])
			z.remove(z[1])
		l.append(z[0])
		z = [1, 2, 3]
	else:
		flag = 0
		break
if flag == 1:
	print('YES')
else:
	print('NO')


n = int(input())
a = [1, 2]
f = 'YES'
for i in range(n):
	p = int(input())
	if p not in a:
		f = 'NO'
		break
	else:
		for j in range(1, 4):
			if j not in a:
				a.append(j)
				z = j
		for j in range(3):
			if a[j] != z and a[j] != p:
				a.pop(j)
				break
print(f)


n = int(input())
p = [1, 2]
l = 3
for _ in range(n):
	d = int(input())
	if d == l:
		print('NO')
		exit()
		break
	nl = p[(p.index(d) + 1) % 2]
	del p[(p.index(d) + 1) % 2]
	p.append(l)
	l = nl
print('YES')


n = int(input())
players = [1, 2]
sideline = 3
for i in range(n):
	t = int(input())
	if t in players:
		index = players.index(t)
		tmp = sideline
		if index == 0:
			sideline = players[1]
			players[1] = tmp
		else:
			sideline = players[0]
			players[0] = tmp
	else:
		print('NO')
		exit(0)
print('YES')


n = int(input())
a = []
play = '12'
for i in range(n):
	a.append(int(input()))
i = 0
check = [False] * n
while i != n:
	if a[i] == int(play[0]) or a[i] == int(play[1]):
		if play.count('1') == 1 and play.count('2') == 1:
			play = str(a[i]) + '3'
		elif play.count('1') == 1 and play.count('3') == 1:
			play = str(a[i]) + '2'
		elif play.count('3') == 1 and play.count('2') == 1:
			play = str(a[i]) + '1'
		i += 1
	else:
		print('NO')
		break
if i == n:
	print('YES')


x = input()
z = []
for i in range(int(x)):
	z.append(input())
first = '1'
second = '2'
spect = '3'
flag = True
for i in range(int(x)):
	if z[i] == first:
		temp = second
		second = spect
		spect = temp
	elif z[i] == second:
		temp = first
		first = spect
		spect = temp
	else:
		flag = False
		break
if flag == True:
	print('YES')
else:
	print('NO')


a = [1, 2]
b = 3
for i in range(int(input())):
	q = int(input())
	if q in a:
		if a[0] != q:
			(a[0], b) = (b, a[0])
		else:
			(a[1], b) = (b, a[1])
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
players = set([1, 2, 3])
curr = set([1, 2])
ans = 'YES'
for _ in range(n):
	winner = int(input())
	if winner not in curr:
		ans = 'NO'
		break
	else:
		curr = players - curr
		curr.add(winner)
print(ans)


n = int(input())
a = [1, 2]
d = [1, 2, 3]
for i in range(n):
	aa = int(input())
	if aa in a:
		ii = (a.index(aa) + 1) % 2
		for j in range(3):
			if d[j] not in a:
				a[ii] = d[j]
				break
	else:
		print('NO')
		return
print('YES')


import sys
input = sys.stdin.read()
data = list(map(int, input.split()))
n = data[0]
a = data[1:]
(playing1, playing2, spectate) = (1, 2, 3)
Yes = 1
for i in range(n):
	if a[i] == spectate:
		print('NO')
		Yes = 0
		break
	elif a[i] == playing1:
		(playing2, spectate) = (spectate, playing2)
	else:
		(playing1, spectate) = (spectate, playing1)
if Yes:
	print('YES')


s = 3
for i in range(int(input())):
	d = int(input())
	if s + d == 6:
		print('NO')
		exit()
	s = 6 - s + d
print('YES')


n = int(input())
a = [int(input()) for i in range(n)]
(p1, p2, p3) = (1, 2, 3)
for i in a:
	if p1 != i and p2 != i:
		print('NO')
		exit(0)
	elif p1 != i:
		(p1, p3) = (p3, p1)
	else:
		(p2, p3) = (p3, p2)
print('YES')


n = int(input())
s = 3
ok = 1
for i in range(0, n):
	a = int(input())
	if a == s:
		ok = 0
		break
	if a != 1 and s != 1:
		s = 1
	elif a != 2 and s != 2:
		s = 2
	else:
		s = 3
if ok == 1:
	print('YES')
else:
	print('NO')


l = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
n = t()
loss = 0
for i in range(n):
	x = t()
	if loss == 0:
		if x == 3:
			print('NO')
			break
		else:
			loss = 3 - x
	elif loss != x:
		loss = 6 - (x + loss)
	else:
		print('NO')
		break
else:
	if loss:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	b = int(input())
	a.append(b)
op1 = 1
op2 = 2
see = 3
ok = True
for i in range(n):
	if a[i] == 1:
		if op1 == 1:
			(op2, see) = (see, op2)
		elif op2 == 1:
			(op1, see) = (see, op1)
		else:
			ok = False
	if a[i] == 2:
		if op1 == 2:
			(op2, see) = (see, op2)
		elif op2 == 2:
			(op1, see) = (see, op1)
		else:
			ok = False
	if a[i] == 3:
		if op1 == 3:
			(op2, see) = (see, op2)
		elif op2 == 3:
			(op1, see) = (see, op1)
		else:
			ok = False
	if ok == False:
		break
if ok:
	print('YES')
else:
	print('NO')


n = int(input())
p = [1, 2, 3]
ans = 'YES'
for i in range(n):
	a = int(input())
	if ans == 'NO':
		continue
	if a == p[-1]:
		ans = 'NO'
	p[0] = a
	p[1] = p[2]
	if p[0] == 1 and p[1] == 2:
		p[2] = 3
	if p[0] == 2 and p[1] == 1:
		p[2] = 3
	if p[0] == 2 and p[1] == 3:
		p[2] = 1
	if p[0] == 1 and p[1] == 3:
		p[2] = 2
	if p[0] == 3 and p[1] == 1:
		p[2] = 2
	if p[0] == 3 and p[1] == 2:
		p[2] = 1
print(ans)


n = int(input())
p = (1, 2)
i = 3
is_valid = True
for _ in range(n):
	w = int(input())
	if not is_valid:
		continue
	if w not in p:
		is_valid = False
	else:
		l = p[0] if w == p[1] else p[1]
		(p, i) = ((w, i), l)
print('YES' if is_valid else 'NO')


q = int(input())
b = True
w = int(input())
if w == 3:
	b = False
t = set([1, 2, 3])
g = set([w, 3])
for i in range(1, q):
	w = int(input())
	if w not in g:
		b = False
	g = {w} | t - g
print('YES' if b else 'NO')


games = int(input())
arr = []
players = '12'
for i in range(games):
	arr.append(input())
for i in range(len(arr)):
	if arr[i] not in players:
		print('NO')
		exit(0)
	tmp = players
	players = '123'
	tmp = tmp.replace(arr[i], '')
	players = players.replace(str(tmp), '')
print('YES')


def R():
	return list(map(int, input().strip().split()))
n = int(input())
possible = [1, 1, 0]
pos = True
for i in range(n):
	a = int(input())
	if possible[a - 1] != 1:
		pos = False
	for j in range(3):
		if possible[j] == 1 and a != j + 1:
			possible[j] = 0
			continue
		if possible[j] == 0:
			possible[j] = 1
if pos:
	print('YES')
else:
	print('NO')


def main():
	n = int(input().strip())
	games = list()
	Player1 = 1
	Player2 = 2
	Spectator = 3
	for i in range(0, n):
		games.append(int(input().strip()))
	for i in range(0, n):
		Winner = games[i]
		if Winner != Player1 and Winner != Player2:
			print('NO')
			return
		elif Winner == Player1:
			temp = Player2
			Player2 = Spectator
			Spectator = temp
		elif Winner == Player2:
			temp = Player1
			Player1 = Spectator
			Spectator = temp
	print('YES')
main()


n = int(input())
gamers = {1: True, 2: True, 3: False}
for i in range(n):
	a = int(input())
	if not gamers[a]:
		print('NO')
		exit()
	else:
		for j in gamers.keys():
			if j != a:
				gamers[j] = not gamers[j]
print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 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 main():
	n = I()
	a = [I() for _ in range(n)]
	t = [1, 2]
	for c in a:
		if c not in t:
			return 'NO'
		t = [c, 6 - sum(t)]
	return 'YES'
print(main())


n = int(input())
prev = 0
play = [1, 2]
for x in range(n):
	a = int(input())
	if a not in play:
		print('NO')
		break
	play = [x for x in range(1, 4) if x not in play or (x in play and x == a)]
else:
	print('YES')


a = [1, 2]
for _ in ' ' * int(input()):
	z = int(input())
	if z not in a:
		print('NO')
		exit()
	a = [z, 6 - sum(a)]
print('YES')


n = int(input())
s = 3
spec = 3
for i in range(n):
	x = int(input())
	if x == spec:
		print('NO')
		quit()
	lose = s - x
	spec = lose
	s = 6 - spec
print('YES')


n = int(input())
p1 = 1
p2 = 2
s = 3
x = 'YES'
for i in range(n):
	d = int(input())
	if d == p1:
		(p2, s) = (s, p2)
	elif d == p2:
		(p1, s) = (s, p1)
	else:
		x = 'NO'
print(x)


d = {}
(d[1], d[2], d[3]) = (True, True, False)
n = int(input())
flag = True
for i in range(n):
	x = int(input())
	if d[x] == False:
		flag = False
	else:
		for j in range(1, 4):
			if j == x:
				continue
			if d[j] == True:
				d[j] = False
			elif d[j] == False:
				d[j] = True
if flag:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
member = [1, 2, 3]
team = [1, 2]
for i in range(n):
	check = int(input())
	if check not in team:
		print('NO')
		sys.exit()
	for j in member:
		if j not in team:
			second = j
			break
	team[0] = check
	team[1] = second
print('YES')


l = []
for i in range(int(input())):
	a = int(input())
	l.append(a)
t = [1, 2]
for i in range(len(l)):
	if l[i] not in t:
		print('NO')
		break
	else:
		t[1 - t.index(l[i])] = 6 - sum(t)
else:
	print('YES')


n = int(input())
np = 3
ans = False
for x in range(0, n):
	stuff = int(input())
	if stuff == np and (not ans):
		ans = True
		print('NO')
	if stuff == 1:
		if np == 2:
			np = 3
		else:
			np = 2
	elif stuff == 2:
		if np == 1:
			np = 3
		else:
			np = 1
	elif stuff == 3:
		if np == 1:
			np = 2
		else:
			np = 1
if not ans:
	print('YES')


n = int(input())
a = []
out = 3
in1 = 1
in2 = 2
for i in range(n):
	tmp = int(input())
	if tmp != in1 and tmp != in2:
		print('NO')
		exit(0)
	if in1 == tmp:
		(in2, out) = (out, in2)
	elif in2 == tmp:
		(in1, out) = (out, in1)
print('YES')


n = int(input())
spec = 3
for _ in range(n):
	x = int(input())
	if x == spec:
		print('NO')
		break
	else:
		spec = 6 - spec - x
else:
	print('YES')


n = int(input())
(a, b) = (1, 2)
ok = True
for i in range(n):
	win = int(input())
	if win in [a, b]:
		(a, b) = (win, 6 - a - b)
	else:
		ok = False
print('YES') if ok else print('NO')


n = int(input())
w = {3}
flag = True
for i in range(n):
	x = int(input())
	if {x} == w:
		flag = False
		break
	else:
		w = {1, 2, 3} - w - {x}
print(['NO', 'YES'][flag])


n = int(input())
l = n * [0]
for i in range(n):
	l[i] = int(input())
s = [1, 2]
w = 3
f = 'YES'
for i in range(n):
	if l[i] in s:
		w2 = s[~s.index(l[i])]
		s.remove(s[~s.index(l[i])])
		s.append(w)
		w = w2
	else:
		f = 'NO'
		break
print(f)


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi

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

def si():
	return str(input())

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

def li():
	return list(mi())
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
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

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 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
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph():
	d = {}
	(v, e) = mi()
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d
n = ii()
l = []
for i in range(n):
	x = ii()
	l.append(x)
s = [3]
a = 1
b = 2
f = 0
for i in range(n):
	if s[i] == l[i]:
		f = 1
		print('NO')
		break
	else:
		a = l[i]
		b = s[i]
		if l[i] == 1 and s[i] == 3:
			s.append(2)
		elif l[i] == 1 and s[i] == 2:
			s.append(3)
		elif l[i] == 2 and s[i] == 3:
			s.append(1)
		elif l[i] == 2 and s[i] == 1:
			s.append(3)
		elif l[i] == 3 and s[i] == 1:
			s.append(2)
		elif l[i] == 3 and s[i] == 2:
			s.append(1)
if f == 0:
	print('YES')


n = int(input())
a = []
for i in range(0, n):
	a.append(int(input()))
flag = None
c = 0
if n == 1 and a[0] == 3:
	print('NO')
else:
	for i in range(0, len(a)):
		if a[i] == 1 and flag == None:
			flag = 2
		elif a[i] == 2 and flag == None:
			flag = 1
		elif a[i] == 2 and flag == 1:
			flag = 3
		elif a[i] == 1 and flag == 2:
			flag = 3
		elif a[i] == 1 and flag == 3:
			flag = 2
		elif a[i] == 2 and flag == 3:
			flag = 1
		elif a[i] == 3 and flag == 2:
			flag = 1
		elif a[i] == 3 and flag == 1:
			flag = 2
		else:
			c = 1
			break
	if c == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
playing = [1, 2]
spect = 3
valid = True
for i in range(n):
	w = int(input())
	if w in playing:
		if playing.index(w) == 0:
			l = playing[1]
			del playing[1]
		else:
			l = playing[0]
			del playing[0]
		playing.append(spect)
		spect = l
	else:
		print('NO')
		valid = False
		break
if valid:
	print('YES')


def main():
	n = int(input())
	winners = [0] * n
	for i in range(n):
		winners[i] = int(input())
	player1 = 1
	player2 = 2
	spectator = 3
	i = 0
	wrong_log = False
	while i < n and (not wrong_log):
		if winners[i] == player1:
			tmp = player2
			player2 = spectator
			spectator = tmp
			i += 1
		elif winners[i] == player2:
			tmp = player1
			player1 = spectator
			spectator = tmp
			i += 1
		else:
			wrong_log = True
	print('NO' if wrong_log else 'YES')
main()


class Solution(object):

	def __init__(self):
		self.solve()

	def next(self, type=int):
		temp = list(map(type, input().split()))
		return temp if len(temp) > 1 else temp[0]

	def solve(self):
		players = [1, 2, 3]
		for _ in range(self.next()):
			winner = self.next()
			if winner == players[0]:
				players.append(players.pop(1))
			elif winner == players[1]:
				players.append(players.pop(0))
			else:
				print('NO')
				break
		else:
			print('YES')
Solution()


players = {1: 'Alex', 2: 'Bob', 3: 'Carl'}
(player_one, player_two, spectator, logs, i) = (players[1], players[2], players[3], [], 0)
n = int(input())
if n < 1 or n > 100:
	raise Exception()
while i < n:
	winner = int(input())
	if winner < 1 or winner > 3:
		raise Exception()
	logs.append(winner)
	i += 1
while len(logs):
	winner = logs.pop(len(logs) - len(logs))
	winner_player = players[winner]
	if winner_player != player_one and winner_player != player_two:
		print('NO')
		break
	(winner_player, loser_player) = (player_one if winner_player == player_one else player_two, player_one if winner_player != player_one else player_two)
	(player_one, player_two, spectator) = (winner_player, spectator, loser_player)
	i -= 1
if i == 0:
	print('YES')


z = input
mod = 10 ** 9 + 7
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

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
n = int(z())
s = 3
for i in range(n):
	w = int(z())
	if s == w:
		print('NO')
		exit(0)
	s = 6 - w - s
print('YES')


n = int(input())
f = 1
s = 2
new = 3
for i in range(n):
	a = int(input())
	if f == a:
		(new, s) = (s, new)
	elif s == a:
		(f, s, new) = (s, new, f)
	elif a == new:
		print('NO')
		exit()
print('YES')


import sys
input()
x = {3}
ans = 'YES'
for i in map(int, sys.stdin):
	if i in x:
		ans = 'NO'
	x = {1, 2, 3} - {i} - x
print(ans)


n = int(input())
k = 3
for i in range(n):
	s = int(input())
	if s == k:
		print('NO')
		exit()
	k = 6 - k - s
print('YES')


def solve():
	on1 = 1
	on2 = 2
	off = 3
	for i in range(int(input())):
		win = int(input())
		if win == on1:
			(on2, off) = (off, on2)
		elif win == on2:
			(on1, off) = (off, on1)
		else:
			return 'NO'
	return 'YES'
print(solve())


import math
n = input()
n = int(n)
x = []
for i in range(n):
	num = input()
	num = int(num)
	x.append(num)
a = [1, 2, 3]
spectator = 3
isPossible = True
for num in x:
	players = [int(players) for players in a if players != spectator]
	if num not in players:
		isPossible = False
		break
	players.remove(num)
	spectator = players[0]
if isPossible:
	print('YES')
else:
	print('NO')


n = int(input())
game = []
i = 0
while i < n:
	game.append(int(input()))
	i += 1
l = [1, 2]
i = 0
t = 1
while i < n:
	if l.count(game[i]) == 0:
		t = 0
		break
	else:
		if l.count(1) == 0:
			l.append(1)
		if l.count(2) == 0:
			l.append(2)
		if l.count(3) == 0:
			l.append(3)
		if game[i] == l[0]:
			l.pop(1)
		else:
			l.pop(0)
		i += 1
if t == 0:
	print('NO')
else:
	print('YES')


(one, two) = (1, 2)
printed = False
spec = 3
for _ in range(int(input())):
	x = int(input())
	if spec == x:
		print('NO')
		printed = True
		break
	if one == x:
		(one, two, spec) = (x, spec, two)
	else:
		(one, two, spec) = (spec, x, one)
if not printed:
	print('YES')


n = int(input())
w = []
for _ in range(n):
	w.append(int(input()))
s = 3
for i in w:
	if i == s:
		print('NO')
		exit()
	s = 6 - s - i
print('YES')


n = int(input())
flag = 0
possible_winners = {1, 2}
curr_not_playing = 3
while n > 0:
	winner = int(input())
	if winner not in possible_winners:
		flag = 1
	else:
		for i in possible_winners:
			if i != winner:
				looser = i
				break
		possible_winners.add(curr_not_playing)
		curr_not_playing = looser
		possible_winners.remove(looser)
	n = n - 1
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
(a, b, c) = (1, 2, 3)
for i in range(n):
	w = int(input())
	if w != a and w != b:
		print('NO')
		exit()
	if w == a:
		(b, c) = (c, b)
	else:
		(a, c) = (c, a)
print('YES')


n = int(input())
k = (1, 2)
b = 3
a = 1
for x in range(n):
	m = int(input())
	if m not in k:
		a = 0
	k = (b, m)
	b = 6 - b - m
if a == 0:
	print('NO')
else:
	print('YES')


n = int(input())
flag = 0
s = 3
for i in range(n):
	a = int(input())
	if a == s:
		flag = 1
		break
	s = 6 - s - a
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
wins = [int(input()) for _ in range(n)]
if wins[0] == 3:
	print('NO')
	exit()
prev_win = wins[0]
prev_loser = 1 if wins[0] == 2 else 2
prev_spec = 3
for i in range(1, n):
	curr = wins[i]
	if curr == prev_loser:
		print('NO')
		break
	else:
		tmp = prev_loser
		prev_loser = prev_spec if curr != prev_spec else prev_win
		prev_win = curr
		prev_spec = tmp
else:
	print('YES')


n = int(input())
proshliyProigr = 0
b = True
for i in range(n):
	s = int(input())
	if proshliyProigr == s:
		b = False
		break
	elif i == 0:
		if s == 1:
			proshliyProigr = 2
		elif s == 2:
			proshliyProigr = 1
		else:
			b = False
			break
	elif (s == 1 or proshliyProigr == 1) and (s == 2 or proshliyProigr == 2):
		proshliyProigr = 3
	elif (s == 2 or proshliyProigr == 2) and (s == 3 or proshliyProigr == 3):
		proshliyProigr = 1
	else:
		proshliyProigr = 2
if b:
	print('YES')
else:
	print('NO')


n = int(input())
players = [1, 2]
specs = [3]
state = 'YES'
for i in range(n):
	x = int(input())
	if x not in players:
		state = 'NO'
		break
	for j in range(2):
		if players[j] != x:
			e = j
	temp = players.pop(e)
	players.append(specs[0])
	specs.pop()
	specs.append(temp)
print(state)


qtd = int(input())
resp = 'YES'
(j1, j2) = (1, 2)
es = 3
w = int(input())
if w == es:
	resp = 'NO'
if w == j1:
	(j2, es) = (es, j2)
else:
	(j1, es) = (es, j1)
for _ in range(qtd - 1):
	w = int(input())
	if w == es:
		resp = 'NO'
	if w == j1:
		(j2, es) = (es, j2)
	else:
		(j1, es) = (es, j1)
print(resp)


num_games = int(input())
curr_players = set((1, 2))
off_player = 3
possible = True
for i in range(num_games):
	winner = int(input())
	if winner in curr_players:
		new_players = set((winner, off_player))
		off_player = (curr_players - new_players).pop()
		curr_players = new_players
	else:
		possible = False
		break
if possible:
	print('YES')
else:
	print('NO')


n = int(input())
(p1, p2) = (1, 2)
valid = True
for _ in range(n):
	a = int(input())
	if not valid:
		continue
	if a != p1 and a != p2:
		valid = False
	s = 6 - p1 - p2
	if a == p1:
		p2 = s
	else:
		p1 = s
if valid:
	print('YES')
else:
	print('NO')


n = int(input())
first_player = 1
second_player = 2
watching = 3
flag = 0
c = 0
for i in range(n):
	x = int(input())
	if x == watching:
		flag = 1
	if x == first_player:
		(watching, second_player) = (second_player, watching)
	elif x == second_player:
		(watching, first_player) = (first_player, watching)
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
fp = 1
sp = 2
spec = 3
f = False
for i in range(n):
	lw = int(input())
	if lw == sp:
		(spec, fp) = (fp, spec)
	elif lw == fp:
		(spec, sp) = (sp, spec)
	else:
		f = True
		break
if f:
	print('NO')
else:
	print('YES')


n = int(input())
spec = set([1, 2, 3])
curr_players = set([1, 2])
flg = 'YES'
for i in range(n):
	winner = int(input())
	if winner not in curr_players:
		flg = 'NO'
		break
	else:
		curr_players = spec - curr_players
		curr_players.add(winner)
		flg = 'YES'
print(flg)


n = int(input())
p = [1, 2]
o = 3
for _ in range(n):
	a = int(input())
	if a in p:
		(p[(p.index(a) + 1) % 2], o) = (o, p[(p.index(a) + 1) % 2])
	else:
		print('NO')
		exit(0)
print('YES')


n = int(input())
a = [1, 2]
ans = 1
for i in range(n):
	j = int(input())
	if j in a:
		a = [j, 6 - sum(a)]
	else:
		ans = 0
if ans == 1:
	print('YES')
else:
	print('NO')


Game = [1, 2]
n = int(input())
ans = 'YES'
for i in range(n):
	vinner = int(input())
	loser = sum(Game) - vinner
	k = 6 - sum(Game)
	if vinner in Game:
		Game.append(k)
		Game.pop(Game.index(loser))
	else:
		ans = 'NO'
print(ans)


n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = int(input())
(a, b, c) = (0, 0, 0)
ans = True
for i in range(n):
	if i == 0:
		if arr[0] == 1:
			a = 1 - a
			c = 1 - c
		elif arr[0] == 2:
			b = 1 - b
			c = 1 - c
		else:
			ans = False
	elif arr[i] == 1:
		if a:
			b = 1 - b
			c = 1 - c
		else:
			ans = False
			break
	elif arr[i] == 2:
		if b:
			a = 1 - a
			c = 1 - c
		else:
			ans = False
			break
	elif c:
		a = 1 - a
		b = 1 - b
	else:
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


n = int(input())
log_list = []
for i in range(n):
	log_list.append(int(input()))
spectator = 3
current_game = [1, 2]
for (index, game) in enumerate(log_list):
	if game == spectator:
		print('NO')
		break
	del current_game[current_game.index(game)]
	current_game.append(spectator)
	spectator = current_game[0]
	del current_game[0]
	current_game.append(game)
else:
	print('YES')


n = int(input())
k = [1, 2, 3]
match = [1, 2]
flag = 0
c = []
for i in range(n):
	a = int(input())
	c.append(a)
if c[0] == 3:
	print('NO')
else:
	for i in range(n):
		if c[i] not in match:
			flag = 1
			print('NO')
			break
		else:
			for item in k:
				if item not in match:
					break
			match = []
			match.append(c[i])
			match.append(item)
	if flag == 0:
		print('YES')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
players = {1, 2}
for i in range(N):
	a = int(input())
	if a not in players:
		print('NO')
		return
	np = {1, 2, 3} - players
	players = np | {a}
print('YES')


n = int(input())
l = [True, True, False]
bad = False
for i in range(0, n):
	x = int(input())
	if not l[x - 1]:
		bad = True
		print('NO')
		break
	else:
		l[0] = not l[0]
		l[1] = not l[1]
		l[2] = not l[2]
		l[x - 1] = True
if not bad:
	print('YES')


n = int(input())
g = []
for i in range(n):
	g.append(int(input()))
(x, y, z) = (1, 2, 3)
for i in range(n):
	if g[i] == z:
		print('NO')
		break
	elif g[i] == x:
		(y, z) = (z, y)
	else:
		(x, z) = (z, x)
if i == n - 1 and g[i] != z:
	print('YES')


l = []
for i in range(int(input())):
	l.append(int(input()))
s = 3
for x in l:
	if s == x:
		print('NO')
		break
	s = 6 - x - s
else:
	print('YES')


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
k = 3
f = 0
for i in range(n):
	if l[i] == k:
		f = 1
		break
	else:
		k = 6 - k - l[i]
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
l = [int(input()) for i in range(n)]
x = 3
y = True
for i in range(n):
	if i == 0:
		if l[i] == x:
			y = False
			print('NO')
			break
	elif l[i] != l[i - 1] and l[i] != x:
		print('NO')
		y = False
		break
	elif x != l[i]:
		x = 6 - l[i] - x
	else:
		x = 6 - l[i] - l[i - 1]
if y:
	print('YES')


def givedif(a, b):
	(a, b) = list(sorted([a, b]))
	if a == 1:
		if b == 2:
			return 3
		return 2
	return 1
n = int(input())
ini = 3
ans = 'YES'
for i in range(n):
	s = int(input())
	if ini == s:
		ans = 'NO'
		break
	ini = givedif(ini, s)
print(ans)


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string 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

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:
			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 = int(z())
a = []
for _ in range(num):
	a.append(int(z()))
s = 3
for i in a:
	if i == s:
		print('NO')
		exit()
	l = 6 - i - s
	s = l
print('YES')


n = int(input())
c = []
players = [1, 1, 0]
score = [0, 0, 0]
k = 1
for i in range(n):
	a = int(input())
	c.append(a)
for j in range(n):
	for u in range(3):
		if players[u] == 0 and u != c[j] - 1:
			score[u] = 1
		if players[u] == 1 and u != c[j] - 1:
			score[u] = -1
	for y in range(3):
		players[y] += score[y]
	score = [0, 0, 0]
	if players[c[j] - 1] == 0:
		k -= 100
if k > 0:
	print('YES')
else:
	print('NO')


n = int(input())
p1 = 1
p2 = 2
s = 3
ans = 1
for i in range(n):
	x = int(input())
	if x == p1:
		t = p2
		p2 = s
		s = t
	elif x == p2:
		t = p1
		p1 = s
		s = t
	else:
		ans = 0
		break
print('YES' if ans else 'NO')


from sys import stdin, stdout
import bisect

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

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

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

def si():
	return stdin.readline()
player = [True, True, False]
for i in range(ii()):
	a = ii() - 1
	if not player[a]:
		print('NO')
		break
	for i in range(3):
		player[i] = not player[i]
	player[a] = not player[a]
else:
	print('YES')


n = int(input())
l = []

def nxt(x):
	if x == 3:
		return 3
	if x == 5:
		return 1
	if x == 4:
		return 2
for i in range(n):
	l.append(int(input()))
game = [1, 2]
b = 1
for i in l:
	if i in game:
		(game[0], game[1]) = (i, nxt(game[0] + game[1]))
	else:
		b = 0
		break
if b == 0:
	print('NO')
else:
	print('YES')


n = int(input())
x = 1
y = 2
c = 0
l = []
for i in range(n):
	g = int(input())
	l.append(g)
for g in l:
	if g == x:
		y = 6 - x - y
	elif g == y:
		x = 6 - x - y
	else:
		print('NO')
		c = 1
		break
if c == 0:
	print('YES')


n = int(input())
sewer = 3
b = 0
for i in range(n):
	c = int(input())
	if c == sewer:
		b = 1
		break
	for j in range(1, 4):
		if j != sewer and j != c:
			sewer = j
			break
if b:
	print('NO')
else:
	print('YES')


aa = int(input())
a = []
step = aa
a.append(1)
a.append(2)
ans = 0
while aa > 0:
	aa -= 1
	x = int(input())
	if 1 not in a and x in a:
		ans += 1
		a.clear()
		a.append(1)
		a.append(x)
	elif 2 not in a and x in a:
		ans += 1
		a.clear()
		a.append(2)
		a.append(x)
	elif 3 not in a and x in a:
		ans += 1
		a.clear()
		a.append(3)
		a.append(x)
	else:
		print('NO')
		break
if ans == step:
	print('YES')


n = int(input())
(p1, p2, sp) = (1, 2, 3)
incorrect = False
while n:
	n -= 1
	win = int(input())
	if not incorrect:
		if win == sp:
			incorrect = True
		elif win == p1:
			(p2, sp) = (sp, p2)
		elif win == p2:
			(p1, sp) = (sp, p1)
if incorrect:
	print('NO')
else:
	print('YES')


n = int(input())
l = [True, True, False]
flag = True
for i in range(n):
	x = int(input())
	if not l[x - 1]:
		flag = False
		break
	l[x - 1] = True
	for j in range(0, 3):
		if l[j] and j != x - 1:
			l[j] = False
		else:
			l[j] = True
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
flag = True
old_spect = 3
new_spect = 3
for x in range(n):
	val = int(input())
	if not flag:
		continue
	if val == new_spect:
		flag = False
		continue
	list1 = [1, 2, 3]
	list1.remove(old_spect)
	list1.remove(val)
	new_spect = list1[0]
	old_spect = new_spect
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
o = 'YES'
x = {'1': 1, '2': 1}
s = '3'
for _ in range(n):
	w = input()
	if x.get(w) is None:
		o = 'NO'
		continue
	nx = {w: 1, s: 1}
	del x[w]
	s = list(x.keys())[0]
	x = nx
print(o)


f = 0
n = int(input())
p1 = 1
p2 = 2
sp = 3
for _ in range(n):
	w = int(input())
	if w == sp:
		f = -1
		break
	if w == 1:
		p1 = 1
		if sp == 3:
			p2 = 3
			sp = 2
		else:
			sp = 3
			p2 = 2
	if w == 2:
		p1 = 2
		if sp == 3:
			p2 = 3
			sp = 1
		else:
			sp = 3
			p2 = 1
	if w == 3:
		p1 = 3
		if sp == 2:
			p2 = 2
			sp = 1
		else:
			sp = 2
			p2 = 1
	if sp == p1 or sp == p2:
		f = -1
		break
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
playing1 = 1
playing2 = 2
whitch = 3
error = 0
for i in range(n):
	win = int(input())
	if playing1 != win and whitch != win:
		(playing1, whitch) = (whitch, playing1)
	elif playing2 != win and whitch != win:
		(playing2, whitch) = (whitch, playing2)
	else:
		error = 1
if error == 1:
	print('NO')
else:
	print('YES')


n = int(input())
b = 3
for i in range(n):
	a = int(input())
	if a == b:
		print('NO')
		exit(0)
	else:
		b = 6 - b - a
print('YES')


def solve(n):
	pa = 1
	pb = 2
	s = 3
	for _ in range(n):
		w = int(input())
		if w == pa:
			(pb, s) = (s, pb)
		elif w == pb:
			(pa, s) = (s, pa)
		else:
			return 'NO'
	return 'YES'
n = int(input())
print(solve(n))


k = int(input().strip().split()[0])
sp = 3
answer = 'YES'
for _ in range(k):
	i = int(input().strip().split()[0])
	if i == sp:
		answer = 'NO'
		break
	else:
		sp = 6 - i - sp
print(answer)


n = int(input())
a = set([1, 2])
b = set([1, 2, 3])
for _ in range(n):
	x = int(input())
	if x in a:
		a = b - a | set([x])
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
table = [1, 2]
done = 0
for x in range(n):
	winner = int(input())
	if not done:
		if winner not in table:
			done = 1
		if winner == 1:
			if 2 in table:
				table = [1, 3]
			else:
				table = [2, 1]
		elif winner == 2:
			if 1 in table:
				table = [2, 3]
			else:
				table = [1, 2]
		elif 2 in table:
			table = [1, 3]
		else:
			table = [2, 3]
if done:
	print('NO')
else:
	print('YES')


x = int(input())
k = [1, 2]
w = 0
for i in range(x):
	n = int(input())
	if k.count(n) == 0:
		w = 1
		break
	k[1 - k.index(n)] = 6 - k[0] - k[1]
if w == 1:
	print('NO')
else:
	print('YES')


n = int(input())
(p1, p2) = (1, 2)
sp = 3
b = True
for i in range(n):
	x = int(input())
	if x == p1:
		(p2, sp) = (sp, p2)
	elif x == p2:
		(p1, sp) = (sp, p1)
	else:
		print('NO')
		b = False
		break
if b:
	print('YES')


k = int(input().rstrip())
(a, b, c) = (1, 1, 0)
flag = 1
for i in range(k):
	p = int(input().rstrip())
	if p == 3 and c == 0 or (p == 2 and b == 0) or (p == 1 and a == 0):
		flag = 0
		break
	if p == 1:
		(a, b, c) = (a, c, b)
	elif p == 2:
		(a, b, c) = (c, b, a)
	else:
		(a, b, c) = (b, a, c)
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
playerSum = 3
inspector = 3
loser = None
isPoss = True
for i in range(n):
	winner = int(input())
	if winner == inspector:
		isPoss = False
		break
	loser = playerSum - winner
	(playerSum, inspector) = (winner + inspector, loser)
if isPoss:
	print('YES')
else:
	print('NO')


(p1, p2, s) = (1, 2, 3)
n = int(input())
situation = True
for i in range(n):
	winner = int(input())
	if winner == p1:
		(p2, s) = (s, p2)
	elif winner == p2:
		(p1, s) = (s, p1)
	elif winner == s:
		situation = False
		break
print('YES' if situation else 'NO')


n = int(input())
players = [1, 2]
spec = 3
for j in range(n):
	i = int(input())
	if i not in players:
		print('NO')
		exit(0)
	else:
		winner = i
		players.remove(i)
		loser = int(players[0])
		players = [winner, spec]
		spec = loser
print('YES')


import sys
uset = {1, 2, 3}
spec = {3}
n = int(input())
for i in range(n):
	k = int(input())
	set1 = set()
	set1 = set1.union({k})
	set1 = set1.union(spec)
	if len(set1) < 2:
		print('NO')
		sys.exit()
	spec = uset.difference(set1)
print('YES')


n = int(input())
trg = False
s = ['free', 'free', 'spectate']
for i in range(n):
	r = int(input())
	if r == 1 and s[1] == 'free' and (s[2] == 'spectate'):
		s[1] = 'spectate'
		s[2] = 'free'
	elif r == 1 and s[1] == 'spectate' and (s[2] == 'free'):
		s[1] = 'free'
		s[2] = 'spectate'
	elif r == 2 and s[0] == 'free' and (s[2] == 'spectate'):
		s[0] = 'spectate'
		s[2] = 'free'
	elif r == 2 and s[0] == 'spectate' and (s[2] == 'free'):
		s[0] = 'free'
		s[2] = 'spectate'
	elif r == 3 and s[0] == 'free' and (s[1] == 'spectate'):
		s[0] = 'spectate'
		s[1] = 'free'
	elif r == 3 and s[0] == 'spectate' and (s[1] == 'free'):
		s[0] = 'free'
		s[1] = 'spectate'
	else:
		trg = True
		break
print('YNEOS'[trg::2])


def isPossible(order):
	currentPlayers = [1, 2]
	for player in order:
		if player in currentPlayers:
			currentPlayers = [player, 6 - sum(currentPlayers)]
		else:
			return 'NO'
	return 'YES'
order = []
lines = int(input())
for line in range(lines):
	i = int(input())
	order.append(i)
print(isPossible(order))


n = int(input())
play1 = 1
play2 = 2
watch = 3
for i in range(n):
	x = int(input())
	if x == play1:
		(play2, watch) = (watch, play2)
	elif x == play2:
		(play1, watch) = (watch, play1)
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
log = []
for i in range(n):
	log.append(int(input()))
players = [1, 2]
possibelity = 'YES'
for winner in log:
	if winner in players:
		players = [winner, 6 - sum(players)]
	else:
		possibelity = 'NO'
print(possibelity)


A = B = True
C = False
n = int(input())
for i in range(n):
	win = int(input())
	if win == 1 and A == True:
		(B, C) = (C, B)
	elif win == 2 and B == True:
		(A, C) = (C, A)
	elif win == 3 and C == True:
		(A, B) = (B, A)
	else:
		print('NO')
		exit(0)
print('YES')


n = int(input())
numList = []
answer = 0
for i in range(0, n):
	item = int(input())
	numList.append(item)
player1 = 'Aleksei'
player2 = 'Boris'
nextPlayer = 'Vasilii'
playerList = [player1, player2, nextPlayer]
for i in range(0, n):
	if numList[i] == 1:
		if player1 == 'Aleksei':
			(player2, nextPlayer) = (nextPlayer, player2)
		elif player2 == 'Aleksei':
			(player1, nextPlayer) = (nextPlayer, player1)
		else:
			answer = 'NO'
			break
	elif numList[i] == 2:
		if player1 == 'Boris':
			(player2, nextPlayer) = (nextPlayer, player2)
		elif player2 == 'Boris':
			(player1, nextPlayer) = (nextPlayer, player1)
		else:
			answer = 'NO'
			break
	elif numList[i] == 3:
		if player1 == 'Vasilii':
			(player2, nextPlayer) = (nextPlayer, player2)
		elif player2 == 'Vasilii':
			(player1, nextPlayer) = (nextPlayer, player1)
		else:
			answer = 'NO'
			break
if answer != 'NO':
	print('YES')
else:
	print('NO')


n = int(input())
(a, b) = (1, 2)
for i in range(n):
	c = int(input())
	if c == a:
		b ^= a
	elif c == b:
		a ^= b
	else:
		exit(print('NO'))
print('YES')


def check(game_idx___winner, player1, player2):
	for winner in game_idx___winner:
		watcher = 6 - player1 - player2
		if winner == watcher:
			return False
		if player1 != winner:
			player1 = watcher
		if player2 != winner:
			player2 = watcher
	return True
games_nr = int(input())
game_idx___winner = [int(input()) for x in range(games_nr)]
player1 = 1
player2 = 2
if check(game_idx___winner, player1, player2):
	print('YES')
	quit()
print('NO')


n = int(input())
curf = 1
curs = 2
for i in range(n):
	h = int(input())
	lft = 6 - curf - curs
	if h == curf:
		curs = lft
	elif h == curs:
		curf = lft
	else:
		print('NO')
		exit(0)
print('YES')


n = int(input())
playing = [1, 2]
pending = 3
check = True
for i in range(n):
	next = int(input())
	if next == pending:
		check = False
		break
	elif next == playing[0]:
		(pending, playing[1]) = (playing[1], pending)
	else:
		(pending, playing[0]) = (playing[0], pending)
if check:
	print('YES')
else:
	print('NO')


n = int(input())
lst = []
for x in range(n):
	x = int(input())
	lst.append(x)
i = 3
flag = True
for x in lst:
	if i == x:
		flag = False
		break
	elif i + x == 4:
		i = 2
	elif i + x == 5:
		i = 1
	else:
		i = 3
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
spec = 3
for i in range(n):
	k = int(input())
	if k == spec:
		print('NO')
		break
	spec = list(set([1, 2, 3]) - set([k, spec]))[0]
else:
	print('YES')


def valid(winners, not_playing):
	for w in winners:
		if not_playing == w:
			return False
		if w != 1 and not_playing != 1:
			not_playing = 1
		elif w != 2 and not_playing != 2:
			not_playing = 2
		elif w != 3 and not_playing != 3:
			not_playing = 3
	return True
N = int(input())
winners = []
for _ in range(0, N):
	winners.append(int(input()))
if valid(winners, 3):
	print('YES')
else:
	print('NO')


num_games = int(input())
roster = (1, 2)
for game in range(num_games):
	winner = int(input())
	if winner in roster:
		roster = (winner, 6 - sum(roster))
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
p = [1, 2, 3]
isOk = True
while n:
	n -= 1
	r = int(input())
	if r == p[0]:
		(p[1], p[2]) = (p[2], p[1])
	elif r == p[1]:
		(p[0], p[2]) = (p[2], p[0])
	else:
		isOk = False
if isOk:
	print('YES')
else:
	print('NO')


games = int(input())
playing = [1, 2]
watching = 3
right = 1
for i in range(games):
	winner = int(input())
	if winner == watching:
		right = 0
		print('NO')
		break
	else:
		if winner == playing[0]:
			losing = playing[1]
		else:
			losing = playing[0]
		playing.append(watching)
		watching = losing
		playing.remove(losing)
if right == 1:
	print('YES')


n = int(input())
tmp = 3
for i in range(n):
	a = int(input())
	if a == tmp:
		print('NO')
		exit()
	tmp = 6 - a - tmp
print('YES')


n = int(input())
games = [int(input()) for __ in range(n)]
(c1, c2) = (1, 2)
for win in games:
	if c1 == win:
		c2 = 6 - c1 - c2
	elif c2 == win:
		c1 = 6 - c1 - c2
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = [1, 2, 3]
for i in range(n):
	w = int(input())
	if a[0] != w and a[1] != w:
		print('NO')
		quit()
	if a[0] == w:
		(a[1], a[2]) = (a[2], a[1])
	else:
		(a[0], a[2]) = (a[2], a[0])
print('YES')


n = int(input())
s = 3
l = [1, 2]
for i in range(n):
	w = int(input())
	if l[1] == w:
		temp = l[0]
		l[0] = s
		s = temp
	elif l[0] == w:
		temp = l[1]
		l[1] = s
		s = temp
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
a = [1, 2]
b = 3
chave = True
for i in range(n):
	tentativa = int(input())
	if tentativa == b:
		chave = False
	if a[0] == tentativa:
		x = a[1]
		a[1] = b
		b = x
	else:
		x = a[0]
		a[0] = b
		b = x
if chave:
	print('YES')
else:
	print('NO')


def main():
	n = int(input())
	game_log = []
	for _ in range(0, n):
		game_log.append(int(input()))
	if game_log[0] == 3:
		print('NO')
		return
	playing = [True, True, False]
	for game in game_log:
		if not playing[game - 1]:
			print('NO')
			return
		playing[game - 1] = False
		playing = [not x for x in playing]
	print('YES')
main()


out = 'C'
num = int(input())
fifa = 'Yes'
for i in range(num):
	a = int(input())
	if out == 'C' and a == 3:
		fifa = 'No'
		break
	if out == 'B' and a == 2:
		fifa = 'No'
		break
	if out == 'A' and a == 1:
		fifa = 'No'
		break
	if out == 'C' and a == 1:
		out = 'B'
		continue
	if out == 'C' and a == 2:
		out = 'A'
		continue
	if out == 'B' and a == 1:
		out = 'C'
		continue
	if out == 'B' and a == 3:
		out = 'A'
		continue
	if out == 'A' and a == 2:
		out = 'C'
		continue
	if out == 'A' and a == 3:
		out = 'B'
		continue
print(fifa)


import os
import sys

def log(*args, **kwargs):
	if os.environ.get('CODEFR'):
		print(*args, **kwargs)
n = int(input())
winner = int(input())
loser = 1 if winner == 2 else 2
spec = 3
if winner == spec:
	print('NO')
	sys.exit(0)
for i in range(n - 1):
	new_winner = int(input())
	if new_winner == loser:
		print('NO')
		sys.exit(0)
	if new_winner == winner:
		swap = loser
		loser = spec
		spec = swap
	else:
		spec = loser
		loser = winner
	winner = new_winner
print('YES')


from sys import stdin

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

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

def linput():
	return list(map(int, stdin.readline().split()))
n = iinput()
(p1, p2) = (1, 2)
ans = 'YES'
while n:
	n -= 1
	w = iinput()
	if w == p1:
		p2 = 6 - (p1 + p2)
	elif w == p2:
		p1 = 6 - (p1 + p2)
	else:
		ans = 'NO'
print(ans)


n = int(input())
g = [1, 2]
m = 3
b = True
for i in range(n):
	a = int(input())
	if not a in g:
		b = False
	if a != g[0]:
		(g[0], m) = (m, g[0])
	else:
		(g[1], m) = (m, g[1])
if b:
	print('YES')
else:
	print('NO')


n = int(input())
lst = []
for i in range(n):
	lst.append(int(input()))
players = [1, 2]
hasPrint = False
for x in lst:
	if not x in players:
		print('NO')
		hasPrint = True
		break
	total = [1, 2, 3]
	total.remove(players[0])
	total.remove(players[1])
	players.clear()
	players.append(x)
	players.append(total[0])
if not hasPrint:
	print('YES')


no_of_matches = int(input())
winners = [int(input()) for i in range(no_of_matches)]
wins = [1, 2, 3]
spectator_won = 0
game = [1, 2]
if winners[0] in game:
	for i in range(1, no_of_matches):
		game = [winners[i - 1]] + [w for w in wins if w not in game]
		if winners[i] not in game:
			spectator_won += 1
			break
	if spectator_won == 0:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


flag = True
n = int(input())
j = ['1', '2']
for i in range(n):
	a = int(input())
	if '1' in j and '2' in j:
		if a == 3:
			flag = False
		else:
			if a == 1:
				j.remove('2')
			else:
				j.remove('1')
			j.append('3')
	elif '1' in j and '3' in j:
		if a == 2:
			flag = False
		else:
			if a == 1:
				j.remove('3')
			else:
				j.remove('1')
			j.append('2')
	elif '3' in j and '2' in j:
		if a == 1:
			flag = False
		else:
			if a == 2:
				j.remove('3')
			else:
				j.remove('2')
			j.append('1')
if flag:
	print('YES')
else:
	print('NO')


import itertools
import re
import math
import getpass
import sys
import string
debug = getpass.getuser() == 'frohe'
files = True
if debug and files:
	sys.stdin = open('test.in')
else:
	pass

def ria():
	return [int(i) for i in input().split()]
n = ria()[0]
pl = [1, 2]
sp = 3
for i in range(n):
	wn = ria()[0]
	if wn not in pl:
		print('NO')
		exit(0)
	pl = [wn] + [sp]
	spn = [1, 2, 3]
	for j in pl:
		spn.remove(j)
	sp = spn[0]
print('YES')


n = int(input())
wins = []
for i in range(n):
	a = int(input())
	wins.append(a)
current = [1, 2]
spec = 3
flag = True
for i in range(len(wins)):
	if wins[i] in current:
		for j in range(len(current)):
			if current[j] != wins[i]:
				temp = current[j]
				current[j] = spec
				spec = temp
	else:
		print('NO')
		flag = False
		break
if flag:
	print('YES')


n = int(input())
t = [int(input()) for _ in range(n)]
flag = True
i = 1
mark = 1 if t[0] == 2 else 2
playing = [t[0], 3]
if t[0] == 3:
	flag = False
	print('NO')
	i = n + 1
while i < n:
	if t[i] == mark:
		print('NO')
		flag = False
		break
	elif t[i] in playing:
		u = mark
		mark = playing.pop(abs(1 - playing.index(t[i])))
		playing.append(u)
		i += 1
		continue
	else:
		mark = playing.pop(abs(1 - playing.index(t[i])))
		playing.append = t[i]
		i += 1
		continue
if flag == True:
	print('Yes')


def solve():
	n = int(input())
	spector = 3
	for _ in range(n):
		p = int(input())
		if p == spector:
			return 'NO'
		spector = 6 - p - spector
	return 'YES'
print(solve())


n = int(input())
i = 1
s = 3
ans = True
while i <= n:
	w = int(input())
	if s == w:
		ans = False
	elif s == 3:
		s = s - w
	elif s == 1:
		if w == 2:
			s = 3
		else:
			s = 2
	elif s == 2:
		if w == 1:
			s = 3
		else:
			s = 1
	i += 1
if ans:
	print('YES')
else:
	print('NO')


a = [1, 2]
c = [1, 2, 3]
f = 0
for x in range(int(input())):
	b = int(input())
	if b not in a:
		print('NO')
		f = 1
		break
	else:
		z = [b]
		for y in c:
			if y not in a:
				z.append(y)
				break
		a = z
if f == 0:
	print('YES')


cur = {1, 2}
t = True
for i in range(int(input())):
	x = int(input())
	if x not in cur:
		t = False
		break
	else:
		ne = {}
		if 1 not in cur:
			ne = {1}
		elif 2 not in cur:
			ne = {2}
		else:
			ne = {3}
		ne.add(x)
		cur = ne
if t:
	print('YES')
else:
	print('NO')


def three(lst):
	count = 3
	for elem in lst:
		if elem == count:
			return 'NO'
		count = 6 - count - elem
	return 'YES'
n = int(input())
a = list()
for i in range(n):
	b = int(input())
	a.append(b)
print(three(a))


n = int(input())
f = True
a = 1
b = 2
for i in range(n):
	k = int(input())
	if k != a and k != b:
		f = False
	l = [a, b]
	if 1 not in l:
		b = 1
	elif 2 not in l:
		b = 2
	else:
		b = 3
	a = k
	if k == b:
		f = False
if f:
	print('YES')
else:
	print('NO')


n = int(input())
x = 1
log = {'P1': 1, 'P2': 2, 'S': 3, 'tmp': 0}
for i in range(n):
	a = int(input())
	if a == log['P1']:
		log['tmp'] = log['P2']
		log['P2'] = log['S']
		log['S'] = log['tmp']
	elif a == log['P2']:
		log['tmp'] = log['P1']
		log['P1'] = log['S']
		log['S'] = log['tmp']
	else:
		x = 0
if x == 0:
	print('NO')
else:
	print('YES')


n = int(input())
c = 3
g = True
for i in range(n):
	t = int(input())
	if t == c:
		g = False
	else:
		c = list({1, 2, 3} ^ {t, c})[0]
if g:
	print('YES')
else:
	print('NO')


n = input()
n = int(n)
can = True
(left, right, other) = (1, 2, 3)
for i in range(n):
	x = input()
	x = int(x)
	if x == other:
		can = False
	elif x == left:
		(left, right, other) = (left, other, right)
	elif x == right:
		(left, right, other) = (other, right, left)
if can:
	print('YES')
else:
	print('NO')


N = int(input())
Play = '12'
Spec = '3'
for i in range(N):
	Ans = input()
	if Ans not in Play:
		print('NO')
		exit()
	Other = str()
	for i in '123':
		if i != Ans and i != Spec[0]:
			Other = i
			break
	Play = Play.replace(Other, Spec[0])
	Spec = Other[:]
print('YES')


n = int(input())
l = {1, 2}
l2 = {1, 2, 3}
con = True
for i in range(n):
	a = int(input())
	if a not in l:
		con = False
	l = l2 - l
	l.add(a)
if con:
	print('YES')
else:
	print('NO')


n = int(input())
resting = 3
no = False
for i in range(n):
	players = [1, 2, 3]
	winner = int(input())
	if no:
		continue
	if winner == resting:
		no = True
		continue
	players.remove(winner)
	players.remove(resting)
	resting = players[0]
if not no:
	print('YES')
else:
	print('NO')
2


n = int(input())
ALEX = 0
BOB = 1
CARL = 2
ingame = [1, 1, 0]

def out(tmp):
	global ingame
	for j in range(len(ingame)):
		if tmp != j:
			ingame[j] = 1 - ingame[j]
for i in range(n):
	x = int(input())
	if x == 1:
		if ingame[ALEX]:
			out(ALEX)
		else:
			print('NO')
			exit(0)
	if x == 2:
		if ingame[BOB]:
			out(BOB)
		else:
			print('NO')
			exit(0)
	if x == 3:
		if ingame[CARL]:
			out(CARL)
		else:
			print('NO')
			exit(0)
print('YES')


n = int(input())
array = []
c = 0
for i in range(n):
	array.append(int(input()))
if array[0] == 1:
	winner = 1
	loser = 2
elif array[0] == 2:
	winner = 2
	loser = 1
else:
	c = -1
	n = 1
	print('NO')
spect = 3
for i in range(n - 1):
	a = array[i + 1]
	if loser == a:
		print('NO')
		c = -1
		break
	elif winner == a:
		b = loser
		loser = spect
		spect = b
	else:
		b = winner
		winner = spect
		spect = loser
		loser = b
if c == 0:
	print('YES')


n = int(input())
watcher = 3
player1 = 1
player2 = 2
flag = True
for i in range(n):
	x = int(input())
	if x == watcher:
		flag = False
	elif x == player1:
		(player2, watcher) = (watcher, player2)
	else:
		(player1, watcher) = (watcher, player1)
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
p1 = 1
p2 = 2
watcher = 3
ans = 0
for i in range(n):
	winner = int(input())
	if winner == watcher:
		ans = 1
	if winner == p1:
		(p2, watcher) = (watcher, p2)
	else:
		(p1, watcher) = (watcher, p1)
if ans == 1:
	print('NO')
else:
	print('YES')


def main():
	read = lambda : tuple(map(int, input().split()))
	n = read()[0]
	state = [1, 1, 0]

	def f(x, state):
		for i in range(3):
			if i != x:
				state[i] = 1 - state[i]
	for i in range(n):
		c = read()[0] - 1
		if state[c] == 0:
			return 'NO'
		f(c, state)
	return 'YES'
print(main())


import sys
n = int(sys.stdin.readline().strip())
entries = []
for line in sys.stdin:
	entries += line.strip()
if entries[0] == 3 or len(entries) != n:
	print('NO')
	sys.exit(0)
players = [1, 2]
for i in range(0, len(entries)):
	if int(entries[i]) not in players:
		print('NO')
		sys.exit(0)
	players = [int(entries[i]), 6 - sum(players)]
print('YES')


n = int(input())
p = 3
for i in range(n):
	x = 1 << int(input()) - 1
	if x & p:
		p ^= 7
		p |= x
	else:
		p = -1
		break
print('YES' if p != -1 else 'NO')


def solve():
	n = int(input())
	games = [1, 2]
	for _ in range(n):
		a = int(input())
		if a not in games:
			return 'NO'
		games = [a] + list(set([1, 2, 3]) - set(games))
	return 'YES'
print(solve())


n = int(input())
cur = [True, True, False]
for i in range(n):
	a = int(input()) - 1
	if cur[a]:
		b = 0
		for j in range(3):
			if not cur[j]:
				b = j
				break
		cur = [False, False, False]
		cur[a] = True
		cur[b] = True
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
w = []
for i in range(0, n):
	w.append(int(input()))
p1 = 1
p2 = 2
flag = True
for i in range(0, n):
	if p1 == w[i]:
		if p1 == 1:
			if p2 == 2:
				p2 = 3
			elif p2 == 3:
				p2 = 2
		elif p1 == 2:
			if p2 == 1:
				p2 = 3
			elif p2 == 3:
				p2 = 1
		elif p2 == 1:
			p2 = 2
		elif p2 == 2:
			p2 = 1
	elif p2 == w[i]:
		if p2 == 1:
			if p1 == 2:
				p1 = 3
			elif p1 == 3:
				p1 = 2
		elif p2 == 2:
			if p1 == 1:
				p1 = 3
			elif p1 == 3:
				p1 = 1
		elif p1 == 1:
			p1 = 2
		elif p1 == 2:
			p1 = 1
	else:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
player1 = 1
player2 = 2
viewer = 3
error = False
for i in range(n):
	win = int(input())
	if player1 != win and viewer != win:
		(player1, viewer) = (viewer, player1)
	elif player2 != win and viewer != win:
		(player2, viewer) = (viewer, player2)
	else:
		error = True
		break
if error:
	print('NO')
else:
	print('YES')


def getnewplayer(lst):
	for i in range(1, 4):
		if i not in lst:
			return i
result = 'YES'
n = int(input())
winners = []
for i in range(n):
	winner = int(input())
	winners.append(winner)
players = (1, 2)
for i in range(0, n):
	if winners[i] not in players:
		result = 'NO'
		break
	else:
		newplayer = getnewplayer(players)
		players = (winners[i], newplayer)
print(result)


n = int(input())
l = []
i = 0
for i in range(n):
	l.append(input())
l1 = ['3']
i = 1
k = 0
while i <= n:
	if l[i - 1] == l1[i - 1]:
		print('NO')
		k = 1
		break
	elif '1' != l[i - 1] and '1' != l1[i - 1]:
		l1.append('1')
	elif '2' != l[i - 1] and '2' != l1[i - 1]:
		l1.append('2')
	elif '3' != l[i - 1] and '3' != l1[i - 1]:
		l1.append('3')
	i += 1
if k != 1:
	print('YES')


n = int(input())
group = set([2, 1])
playerSum = 3
inspector = 3
loser = None
isPoss = True
for i in range(n):
	winner = int(input())
	if winner == inspector:
		isPoss = False
		break
	loser = playerSum - winner
	group.remove(loser)
	group.add(inspector)
	(playerSum, inspector) = (winner + inspector, loser)
if isPoss:
	print('YES')
else:
	print('NO')


n = int(input())
L = []
for i in range(n):
	L.append(int(input()))

def notparti(a, b):
	if a != 1 and b != 1:
		return 1
	elif a != 2 and b != 2:
		return 2
	else:
		return 3

def analy(a, b):
	if a != L[0] and b != L[0]:
		return False
	else:
		ob = notparti(a, b)
		ok = True
		i = 0
		while i < len(L) and ok:
			if L[i] == ob:
				ok = False
			else:
				ob = notparti(ob, L[i])
				i = i + 1
		return ok
res = analy(1, 2)
if res:
	print('YES')
else:
	print('NO')


a = {1, 2}
c = {3}
p = {1, 2, 3}
for _ in ' ' * int(input()):
	z = int(input())
	if z not in a:
		print('NO')
		exit()
	a = (p - (a - {z})).union(c)
	c = p - a
print('YES')


n = int(input())
l = [int(input()) - 1 for _ in range(n)]
res = False
s = {0, 1, 2}
curr = 2
ans = True
for e in l:
	if e == curr:
		ans = False
		break
	curr = list(s - {curr, e})[0]
res |= ans
print('YES' if res else 'NO')


n = int(input())
a = [int(input()) for i in range(n)]
play = [1, 2]
spec = [3]
for i in range(n):
	if a[i] == play[0]:
		spec.append(play[1])
		del play[1]
		play.append(spec[0])
		del spec[0]
	elif a[i] == play[1]:
		spec.append(play[0])
		del play[0]
		play.append(spec[0])
		del spec[0]
	else:
		print('NO')
		exit()
print('YES')


import sys

def check():
	games_played = int(sys.stdin.readline())
	results = []
	for i in range(games_played):
		results.append(int(sys.stdin.readline()[0]))
	log = ['AB']
	for i in range(1, games_played + 1):
		if results[i - 1] is 1:
			if log[i - 1] is 'AB':
				log.append('AC')
			elif log[i - 1] is 'AC':
				log.append('AB')
			else:
				return False
		elif results[i - 1] is 2:
			if log[i - 1] is 'AB':
				log.append('BC')
			elif log[i - 1] is 'BC':
				log.append('AB')
			else:
				return False
		elif results[i - 1] is 3:
			if log[i - 1] is 'AC':
				log.append('BC')
			elif log[i - 1] is 'BC':
				log.append('AC')
			else:
				return False
	return True
if check():
	print('YES')
else:
	print('NO')


n = int(input())
x = 1
y = 2
z = 3
b = 0
for i in range(n):
	a = int(input())
	if a == x:
		b = y
		y = z
		z = b
	elif a == y:
		b = x
		x = z
		z = b
	else:
		print('NO')
		exit()
print('YES')


p = [1, 2, 3]
for i in range(int(input())):
	w = int(input())
	if p[2] == w:
		print('NO')
		exit()
	li = w == p[0]
	(p[li], p[2]) = (p[2], p[li])
print('YES')


n = int(input())
correct = True
A = set([1, 2])
spect = 3
for _ in range(n):
	tmp = int(input())
	if tmp not in A:
		correct = False
		break
	(A, spect) = (set([spect, tmp]), list(A.difference(set([tmp])))[0])
if correct:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
playing = [1, 2]
spec = [3]
for i in l:
	if i in playing:
		ind = playing.index(i)
		if ind == 0:
			sp = playing[1]
			playing.pop(1)
		else:
			sp = playing[0]
			playing.pop(0)
		playing.append(spec[0])
		spec.pop()
		spec.append(sp)
	else:
		print('NO')
		exit()
print('YES')


def main():
	n = lie()
	a = [lie() for i in range(n)]
	spec = 3
	for i in range(n):
		if a[i] == spec:
			print('NO')
			exit()
		if a[i] == 1:
			spec = 2 if spec == 3 else 3
		elif a[i] == 2:
			spec = 1 if spec == 3 else 3
		else:
			spec = 1 if spec == 2 else 2
	print('YES')

def fun(m, n, s, k):
	return

def fun2(s):
	return
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

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

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

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat

def dmain():
	setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
dmain()


n = int(input())
player1 = 1
player2 = 2
spec = 3
flag = 1
for i in range(n):
	c = int(input())
	if c == spec:
		flag = 0
	else:
		d = spec
		spec = player1 + player2 - c
		player1 = c
		player2 = d
if flag == 0:
	print('NO')
else:
	print('YES')


n = int(input())
c = 0
spec = 3
for i in range(n):
	a = int(input())
	if a == spec:
		c = 1
	spec = 6 - spec - a
if c == 0:
	print('YES')
else:
	print('NO')


n = int(input())
now = ['A', 'B']
watcher = ['C']
d = ['A', 'B', 'C']
for i in range(n):
	cur = int(input()) - 1
	if d[cur] not in now:
		print('NO')
		break
	(now, watcher) = (watcher + [d[cur]], [now[0]] if now[0] != d[cur] else [now[1]])
else:
	print('YES')


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
n = int(input())
cp = {1, 2}
for _ in range(n):
	w = int(input())
	if w not in cp:
		print('NO')
		exit()
	elif w == 1:
		if cp == {1, 2}:
			cp = {1, 3}
		else:
			cp = {1, 2}
	elif w == 2:
		if cp == {2, 3}:
			cp = {1, 2}
		else:
			cp = {2, 3}
	elif cp == {1, 3}:
		cp = {2, 3}
	else:
		cp = {1, 3}
print('YES')


n = int(input())
a = 1
b = 2
c = 3
bool = False
for u in range(n):
	w = int(input())
	if w == c:
		print('NO')
		bool = True
		break
	a = w
	b = c
	if a == 1 and b == 2 or (a == 2 and b == 1):
		c = 3
	elif a == 1 and b == 3 or (a == 3 and b == 1):
		c = 2
	else:
		c = 1
if bool == False:
	print('YES')


def code10():
	n = int(input())
	c = 3
	k = 0
	for i in range(n):
		w = int(input())
		if w != c:
			k += 1
		c = 6 - w - c
	if k == n:
		print('YES')
	else:
		print('NO')
code10()


from sys import stdin
n = int(stdin.readline())
winners = []
spectator = 3
possible = True
for i in range(0, n):
	winners.append(int(stdin.readline()))
	if winners[i] == spectator:
		possible = False
		break
	spectator = 6 - spectator - winners[i]
if possible:
	print('YES')
else:
	print('NO')


n = int(input())
(h, h1, f) = ([1, 2, 3], [1, 2], 0)
for i in range(n):
	k = int(input())
	if k not in h1:
		print('NO')
		f = 1
		break
	k1 = list(set(h) - set(h1))[0]
	h1[not h1.index(k)] = k1
if f == 0:
	print('YES')


n = int(input())
op = 3
for i in range(0, n):
	wi = int(input())
	if wi == op:
		print('NO')
		break
	op = 6 - op - wi
else:
	print('YES')


p = 3
a = [1, 2, 3]
k = 0
for i in range(int(input())):
	x = int(input())
	if x == p:
		k = 1
	else:
		p = [i for i in a if i not in [x, p]][0]
print('YES' if k == 0 else 'NO')


n = int(input())
(a, b) = (1, 2)
c = True
m = False
for i in range(n):
	x = int(input())
	if x == a:
		b = 6 - a - b
	elif x == b:
		(a, b) = (b, 6 - a - b)
	else:
		m = True
if m:
	print('NO')
else:
	print('YES')


n = int(input())
x = 1
y = 2
work = True
for i in range(n):
	w = int(input())
	if w == x or w == y:
		y = 6 - x - y
		x = w
	else:
		work = False
if work:
	print('YES')
else:
	print('NO')


def main():
	player = [0] * 4
	playing = 1
	spectating = 0
	player[1] = playing
	player[2] = playing
	player[3] = spectating
	matches = int(input())
	for _ in range(matches):
		winner = int(input())
		if player[winner] == spectating:
			print('NO')
			return
		for i in range(1, 4):
			if i != winner:
				player[i] = 1 - player[i]
	print('YES')
	return
main()


n = int(input())
a = [1, 2]
for i in range(n):
	b = int(input())
	testing = True
	for j in range(2):
		if a[j] == b:
			testing = False
			a[1 - j] = 6 - a[0] - a[1]
	if testing:
		print('NO')
		exit(0)
print('YES')


import sys
n = int(next(sys.stdin))
winners = [int(next(sys.stdin)) for _ in range(n)]
game = {1, 2}
bench = {3}
for w in winners:
	if w not in game:
		print('NO')
		sys.exit()
	tmp = game.copy()
	game = {w}.union(bench)
	bench = tmp - {w}
print('YES')


n = int(input())
a = []
for _ in range(n):
	a.append(int(input()))
plr_1 = 1
plr_2 = 2
spec = 3
for win in a:
	if plr_1 == win:
		(plr_2, spec) = (spec, plr_2)
	elif plr_2 == win:
		(plr_1, plr_2) = (plr_2, plr_1)
		(plr_2, spec) = (spec, plr_2)
	else:
		print('NO')
		break
else:
	print('YES')


(n, r, k) = (int(input()), 0, 3)
for i in range(n):
	b = int(input())
	if b is k:
		r = 1
	else:
		k = 6 - k - b
if r is 0:
	print('YES')
else:
	print('NO')


n = int(input())
j1 = 1
j2 = 2
es = 3
bandera = False
for i in range(0, n):
	a = int(input())
	if a == es:
		bandera = True
	elif a == j2:
		(j1, es) = (es, j1)
	else:
		(j2, es) = (es, j2)
if bandera == True:
	print('No')
else:
	print('Yes')


n = int(input())
w = [int(input()) for _ in range(n)]
t = True
p = [3, 1, 2]
for x in range(0, n):
	if w[x] == p[1]:
		p = [p[2], p[0], p[1]]
	elif w[x] == p[2]:
		p = [p[1], p[2], p[0]]
	else:
		print('NO')
		t = False
		break
if t:
	print('YES')


n = int(input())
l = n
player = ['Alex', 'Bob', 'Carl']
current = ['Alex', 'Bob']
count = 0
i = 0
while n:
	a = int(input())
	if a == 1 and 'Alex' in current:
		if 'Bob' in current:
			current[1] = 'Carl'
		else:
			current[1] = 'Bob'
		current[0] = 'Alex'
		count += 1
	elif a == 2 and 'Bob' in current:
		if 'Alex' in current:
			current[1] = 'Carl'
		else:
			current[1] = 'Alex'
		current[0] = 'Bob'
		count += 1
	elif a == 3 and 'Carl' in current:
		if 'Bob' in current:
			current[1] = 'Alex'
		else:
			current[1] = 'Bob'
		current[0] = 'Carl'
		count += 1
	n -= 1
print('YES' if count == l else 'NO')


numgames = int(input())
(p1, p2, esp) = (1, 2, 3)
while numgames:
	win = int(input())
	if win != esp and win == p1:
		(p1, p2, esp) = (win, esp, p2)
	elif win != esp and win == p2:
		(p2, p1, esp) = (win, esp, p1)
	else:
		print('NO')
		break
	numgames -= 1
if not numgames:
	print('YES')


n = int(input())
abc = [1, 2, 3]
p = [1, 2]
for i in range(n):
	t = int(input())
	if t in p:
		nxt = list(set(abc) ^ set(p))[0]
		p = [t, nxt]
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
winners = []
for i in range(n):
	winners.append(int(input()))
players = [1, 2, 3]
k = True
for i in range(n):
	Mplayers = [1, 2, 3]
	if winners[i] == players[0] or winners[i] == players[1]:
		for j in range(2):
			if players[j] != winners[i]:
				(players[j], players[2]) = (players[2], players[j])
	else:
		k = False
		print('NO')
		break
if k == True:
	print('YES')


n = int(input())
o = 3
for _ in range(n):
	w = int(input())
	if w == o:
		print('NO')
		break
	o = 6 - o - w
else:
	print('YES')


total = [1, 2, 3]
curr = [1, 2]
for _ in range(int(input())):
	winner = int(input())
	if winner not in curr:
		print('NO')
		break
	curr = [winner] + [x for x in total if x not in curr]
else:
	print('YES')


n = int(input())
game = [1, 2]
Failed = False
out = 3
for i in range(n):
	k = int(input())
	if k in game:
		(game[1 - game.index(k)], out) = (out, game[1 - game.index(k)])
	else:
		Failed = True
		break
if Failed:
	print('NO')
else:
	print('YES')


n = int(input())
s = 3
flag = True
for i in range(n):
	j = int(input())
	if j == s:
		flag = False
		break
	s = 6 - j - s
if flag:
	print('YES')
else:
	print('NO')


x = int(input())
a = [int(input()) for i in range(x)]
k = 0
t = 0
t1 = 0
if a[0] == 3:
	print('NO')
	k = 1
elif x == 1:
	if a[0] == 3:
		print('NO')
		k = 1
	else:
		print('YES')
		k = 1
elif a[0] == 1:
	t = 1
	t1 = 2
elif a[0] == 2:
	t = 2
	t1 = 1
for i in range(x - 1):
	if a[i + 1] == t1:
		print('NO')
		k = 1
		break
	elif a[i + 1] == t and t1 == 1 and (t == 2):
		t = 2
		t1 = 3
	elif a[i + 1] == t and t1 == 1 and (t == 3):
		t = 3
		t1 = 2
	elif a[i + 1] == t and t1 == 2 and (t == 1):
		t = 1
		t1 = 3
	elif a[i + 1] == t and t1 == 2 and (t == 3):
		t = 3
		t1 = 1
	elif a[i + 1] == t and t1 == 3 and (t == 1):
		t = 1
		t1 = 2
	elif a[i + 1] == t and t1 == 3 and (t == 2):
		t = 2
		t1 = 1
	else:
		t1 = t
		t = a[i + 1]
if k == 0:
	print('YES')


a = input()
arr = []
player = [1, 2]
spec = 3
boo = True
for i in range(int(a)):
	winner = int(input())
	if winner is spec:
		boo = False
	else:
		loser = 6 - spec - winner
		player = [spec, winner]
		spec = loser
if boo:
	print('YES')
else:
	print('NO')


a = []
for i in range(int(input())):
	a.append(int(input()))
s = 3
f = 1
if len(a) == 1:
	if a[0] == s:
		print('NO')
	else:
		print('YES')
	exit(0)
for i in range(len(a) - 1):
	w = a[i]
	if i == 0 and w == s:
		print('NO')
		f = 0
		break
	if w == 1 and s == 3:
		s = 2
	elif w == 1 and s == 2:
		s = 3
	elif w == 2 and s == 3:
		s = 1
	elif w == 2 and s == 1:
		s = 3
	elif w == 3 and s == 1:
		s = 2
	elif w == 3 and s == 2:
		s = 1
	if a[i + 1] == s:
		print('NO')
		f = 0
		break
if f:
	print('YES')


n = int(input())
Hist = []
for i in range(n):
	Hist.append(int(input()))
F = True
s = 3
for i in range(n):
	w = Hist[i]
	t = 6 - w - s
	if Hist[i] != s:
		s = t
	else:
		F = False
if F:
	print('YES')
else:
	print('NO')


import sys
f = sys.stdin
n = int(f.readline())
c = 0
spec = 3
for i in range(n):
	a = int(f.readline())
	if a == spec:
		c = 1
		break
	spec = 6 - spec - a
if c == 0:
	print('YES')
else:
	print('NO')


n = int(input())
game = [1, 2]
n_game = 3
for i in range(n):
	x = int(input())
	if not x in game:
		print('NO')
		break
	else:
		(game[not game.index(x)], n_game) = (n_game, game[not game.index(x)])
else:
	print('YES')


l = int(input())
espectador = 3
play = [1, 2]
cont = 0
for x in range(0, l):
	c = int(input())
	if play.count(c) > 0:
		cont += 1
		if play[0] == c:
			aux = espectador
			espectador = play[1]
			play[1] = aux
		else:
			aux = espectador
			espectador = play[0]
			play[0] = aux
	else:
		cont = -1
		break
if cont == l:
	print('YES')
else:
	print('NO')


def solve(a):
	e = 3
	for i in a:
		if i == e:
			return 'NO'
		else:
			e = 6 - i - e
	return 'YES'

def main():
	a = [int(input()) for _ in range(int(input()))]
	print(solve(a))
main()


n = int(input())
full = set([1, 2, 3])
pl = set([1, 2])
result = 'YES'
for i in range(n):
	win = int(input())
	if win not in pl:
		result = 'NO'
		break
	pl.remove(win)
	lose = pl.pop()
	pl = full.copy()
	pl.remove(lose)
print(result)


n = int(input())
c = [1, 2]
con = True
for i in range(n):
	p = int(input())
	if p not in c:
		con = False
		break
	elif c == [1, 2] or c == [2, 1]:
		d = c.index(p)
		if d == 0:
			c[-1] = 3
		else:
			c[0] = 3
	elif c == [1, 3] or c == [3, 1]:
		d = c.index(p)
		if d == 0:
			c[-1] = 2
		else:
			c[0] = 2
	elif c == [2, 3] or c == [3, 2]:
		d = c.index(p)
		if d == 0:
			c[-1] = 1
		else:
			c[0] = 1
if con:
	print('YES')
else:
	print('NO')


pl1 = 1
pl2 = 2
spec = 3
wrong = 0
n = int(input())
for i in range(n):
	win = int(input())
	if win == pl1:
		(pl2, spec) = (spec, pl2)
	elif win == pl2:
		(pl1, spec) = (spec, pl1)
	else:
		wrong = 1
if wrong == 0:
	print('YES')
else:
	print('NO')


n = int(input())
out = 3
for _ in range(n):
	win = int(input())
	if win == out:
		print('NO')
		break
	else:
		l = [1, 2, 3]
		l.remove(out)
		l.remove(win)
		out = l[0]
else:
	print('YES')


def ingreso():
	juegos = int(input())
	while juegos != 0:
		juegos = juegos - 1
		juego = int(input())
		comparar(juego)

def comparar(juego):
	global posibles, band
	if posibles.count(juego) == 0:
		band = 'NO'
	else:
		posibles = [juego, buscar()]

def buscar():
	numero = 0
	global posibles
	if posibles.count(1) <= 0:
		numero = 1
	elif posibles.count(2) <= 0:
		numero = 2
	else:
		numero = 3
	return numero
global posibles, aux, band
band = 'YES'
posibles = [1, 2]
aux = [1, 2, 3]
ingreso()
print(band)


n = int(input())
possibilities = [1, 2]
ans = []
while n > 0:
	winner = int(input())
	lst = []
	if winner in possibilities:
		lst.append(winner)
		ans.append('y')
	else:
		ans.append('n')
	if 1 in possibilities and 2 in possibilities:
		lst.append(3)
	elif 2 in possibilities and 3 in possibilities:
		lst.append(1)
	elif 1 in possibilities and 3 in possibilities:
		lst.append(2)
	possibilities = lst
	n -= 1
if 'n' in ans:
	print('NO')
else:
	print('YES')


def sol():
	n = int(input())
	A = []
	for i in range(n):
		A.append(int(input()))
	l = 3
	op = 3
	for i in range(0, n):
		if i == 0:
			if A[i] == 3:
				print('NO')
				return
			else:
				l = 3 - A[i]
				op = 3
		elif A[i] == l:
			print('NO')
			return
		else:
			l = 6 - A[i] - l
			op = A[i]
	print('YES')
sol()


i = input
l = 3
for _ in [0] * int(i()):
	x = int(i())
	if x == l:
		print('NO')
		exit()
	l ^= x
print('YES')


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))

def f(l):
	a = [1, 2]
	for i in l:
		if i not in a:
			return 'NO'
		b = [1, 2, 3]
		for x in a:
			b.remove(x)
		a = [i, b[0]]
	return 'YES'
print(f(l))


n = int(input())
array = [int(input()) for _ in range(n)]
Alex = True
Bob = True
Carl = False
for i in array:
	if i == 1 and Alex is False:
		print('NO')
		quit()
	elif i == 2 and Bob is False:
		print('NO')
		quit()
	elif i == 3 and Carl is False:
		print('NO')
		quit()
	else:
		if i == 1 and Carl == False:
			Carl = True
			Bob = False
		elif i == 1 and Bob == False:
			Carl = False
			Bob = True
		if i == 2 and Carl == False:
			Carl = True
			Alex = False
		elif i == 2 and Alex == False:
			Carl = False
			Alex = True
		if i == 3 and Alex == False:
			Alex = True
			Bob = False
		elif i == 3 and Bob == False:
			Alex = False
			Bob = True
print('YES')


def main():
	N = int(input())
	A = tuple((int(input()) for _ in [0] * N))
	players = [1, 2]
	spectating = 3
	for i in A:
		if i in players:
			loser = players[0] ^ players[1] ^ i
			players = [i, spectating]
			spectating = loser
		else:
			print('NO')
			break
	else:
		print('YES')
main()


import sys
A = B = True
C = False
ans = [True, True, False]
for i in range(int(input())):
	s = int(input())
	if ans[s - 1] == False:
		print('NO')
		sys.exit()
	for j in range(3):
		if j != s - 1 and ans[j] == True:
			ans[j] = False
		else:
			ans[j] = True
print('YES')


def win(a, b):
	b = int(b)
	if b == 1 and 'A' in a:
		if 'B' in a:
			return 'AC'
		else:
			return 'AB'
	if b == 2 and 'B' in a:
		if 'A' in a:
			return 'BC'
		else:
			return 'BA'
	if b == 3 and 'C' in a:
		if 'B' in a:
			return 'AC'
		else:
			return 'BC'
	return '-1'
n = int(input())
st = 'AB'
for i in range(0, n):
	st = win(st, int(input()))
	if str(st) == '-1':
		print('NO')
		quit()
print('YES')


n = int(input())
count = 0
a = 1
b = 2
v = 3
game = [a, b, v]
for _ in range(n):
	result = int(input())
	if result == game[0]:
		(game[1], game[2]) = (game[2], game[1])
	elif result == game[1]:
		(game[0], game[2]) = (game[2], game[0])
	else:
		count = 1
		break
if count == 0:
	print('YES')
else:
	print('NO')


players = [1, 2, 3]
possible = True
n_games = int(input())
for i in range(n_games):
	winner = int(input())
	if winner == players[0]:
		(players[1], players[2]) = (players[2], players[1])
	elif winner == players[1]:
		(players[0], players[2]) = (players[2], players[0])
	else:
		possible = False
		break
if possible:
	print('YES')
else:
	print('NO')


n = input('')
n = int(n)
a1 = '1'
a2 = '2'
other = '3'
flog = 1
for i in range(0, n):
	now = input('')
	if now == a1:
		(a2, other) = (other, a2)
	elif now == a2:
		(a1, other) = (other, a1)
	else:
		flog = 0
		break
if flog:
	print('YES')
else:
	print('NO')


play = [1, 2]
sp = 3
ans = 0
for i in range(int(input())):
	w = int(input())
	if w not in play:
		ans = 1
		break
	s = sum(play) - w
	play.remove(s)
	play.append(sp)
	sp = s
if ans == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
ans = [1, 2, 3]
for i in range(n):
	if a[i] == ans[2]:
		print('NO')
		break
	if ans[1] == a[i]:
		(ans[0], ans[2]) = (ans[2], ans[0])
	else:
		(ans[1], ans[2]) = (ans[2], ans[1])
	if i == n - 1:
		print('YES')


n = int(input())
a = [1, 2, 0, 3]
f = False
for _ in range(n):
	win = int(input())
	if win != a[0] and win != a[1]:
		f = True
		break
	lose = a[1] if win == a[0] else a[0]
	a[0] = win
	a[1] = a[3]
	a[2] = 0
	a[3] = lose
if f:
	print('NO')
else:
	print('YES')


n = int(input())
players = ['A', 'B', 'C']
state = ['A', 'B']
k = True
for i in range(n):
	a = int(input())
	if players[a - 1] in state:
		for o in players:
			if o not in state:
				break
		ind = (state.index(players[a - 1]) + 1) % 2
		state[ind] = o
	else:
		print('NO')
		k = False
		break
if k:
	print('YES')


n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))
a = 1
b = 2
idle = 3
for i in range(n):
	if arr[i] == idle:
		print('NO')
		exit()
	if a == arr[i]:
		(idle, b) = (b, idle)
	elif b == arr[i]:
		(idle, a) = (a, idle)
print('YES')


a = 1
b = 2
c = 0
for _ in range(int(input())):
	n = int(input())
	if n == a:
		if a == 1 and b == 2:
			b = 3
		elif a == 1 and b == 3:
			b = 2
		elif a == 2 and b == 3:
			b = 1
		elif a == 2 and b == 1:
			b = 3
		elif a == 3 and b == 1:
			b = 2
		else:
			b = 1
	elif n == b:
		if a == 1 and b == 2:
			a = 3
		elif a == 1 and b == 3:
			a = 2
		elif a == 2 and b == 3:
			a = 1
		elif a == 2 and b == 1:
			a = 3
		elif a == 3 and b == 1:
			a = 2
		else:
			a = 1
	else:
		c = 1
if c == 0:
	print('YES')
else:
	print('NO')


l = []
for i in range(int(input())):
	l.append(int(input()))
p = {1, 2}
s = 3
for x in l:
	if x not in p:
		print('NO')
		break
	t = {x, s}
	s = list(p - {x})
	s = s[0]
	p = t
else:
	print('YES')


n = int(input())
d = []
for i in range(n):
	d.append(int(input()))
c = set([1, 2])
f = True
for i in d:
	if not i in c:
		f = False
		break
	(a, b) = (c.pop(), c.pop())
	c.add(i)
	c.add(6 - a - b)
print('YES' if f else 'NO')


import sys
import math
import bisect
import itertools

def main():
	A = [1, 2]
	B = []
	for _ in range(int(input())):
		a = int(input())
		B.append(a)
	ans = True
	for a in B:
		if a not in A:
			ans = False
		else:
			b = sum(A) - a
			c = 6 - a - b
			A.remove(b)
			A.append(c)
	if ans:
		print('YES')
	else:
		print('NO')
main()


n = int(input())
(x, y) = (1, 2)
for i in range(n):
	a = int(input())
	if a not in [x, y]:
		print('NO')
		exit(0)
	j = 1
	while j in [x, y]:
		j += 1
	if x != a:
		x = j
	else:
		y = j
print('YES')


def f(s1, s2):
	return 6 - s1 - s2

def test(now, _next):
	global d
	for i in range(len(d)):
		if now == d[i]:
			_next = f(now, _next)
		elif _next == d[i]:
			now = f(_next, now)
		else:
			return False
	return True
n = int(input())
d = []
for i in range(n):
	d.append(int(input()))
if test(1, 2):
	print('YES')
else:
	print('NO')


l = 3
c = int(input())
for _ in range(c):
	i = int(input())
	if i != l:
		s = {1, 2, 3}
		s.remove(l)
		s.remove(i)
		l = s.pop()
	else:
		print('NO')
		exit(0)
print('YES')


a = int(input())
p1 = '1'
p2 = '2'
s = '3'
out = 'YES'
for i in range(0, a):
	g = input()
	if g != p1 and g != p2:
		out = 'NO'
	else:
		if g == p1:
			x = p2
			p1 = g
			p2 = s
			s = x
		if g == p2:
			x = p1
			p1 = g
			p2 = s
			s = x
print(out)


(a, b) = (1, 2)
for _ in range(int(input())):
	n = int(input())
	if a == n or b == n:
		if a == n:
			b = 6 - (a + b)
		else:
			a = 6 - (a + b)
	else:
		print('NO')
		exit()
print('YES')


import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
(N,) = map(int, input().split())
L = [int(input()) for _ in range(N)]
c = {1, 2}
for v in L:
	if v not in c:
		print('NO')
		exit()
	p = {1, 2, 3} - c
	p.add(v)
	c = p
print('YES')


def check(playing, win):
	ingame = []
	out = -1
	for i in range(3):
		if playing[i] == True:
			ingame.append(i)
		else:
			out = i
	if win == out:
		return False
	else:
		return True

def change(playing, win):
	for i in range(3):
		if i == win:
			continue
		else:
			playing[i] = not playing[i]
	return playing

def main():
	n = int(input())
	winners = []
	for i in range(n):
		inp = int(input())
		winners.append(inp)
	playing = [True, True, False]
	for it in range(n):
		win = winners[it]
		go = check(playing, win - 1)
		if go:
			playing = change(playing, win - 1)
		else:
			print('NO')
			return
	print('YES')
	return
main()


n = int(input())
(flag, x, y, nt) = (1, 1, 2, 3)
for _ in range(n):
	a = int(input())
	if a == nt:
		flag = 0
	nt = 6 - nt - a
print('YES') if flag else print('NO')


from collections import Counter, defaultdict
import itertools
import sys

def main():
	n = int(input())
	spec = 3
	poss = True
	for _ in range(n):
		winner = int(input())
		if winner != spec:
			spec = 6 - winner - spec
		else:
			poss = False
	print('YES' if poss else 'NO')
main()


n = int(input())
f = 3
s = 1
for i in range(n):
	z = int(input())
	if z == f:
		s = 0
		break
	else:
		f = 6 - z - f
print('YES' if s else 'NO')


num = input()
list = [None] * int(num)
players = {1, 2}
track = {1, 2, 3}
winner = 0
total = 0
for x in range(0, int(num)):
	list[x] = int(input())
for x in list:
	if x not in players:
		print('NO')
		break
	else:
		winner = x
		players = {winner, (players ^ track).pop()}
		total = total + 1
if total is len(list):
	print('YES')


x = int(input())
f = [1, 2]
flag = 'YES'
for i in range(x):
	z = int(input())
	if z in f:
		if sum(f) % 5 == 4:
			f.append(2)
		elif sum(f) % 5 == 0:
			f.append(1)
		else:
			f.append(3)
		if f.index(z) == 1:
			del f[0]
		else:
			del f[1]
	else:
		flag = 'NO'
print(flag)


n = int(input())
spec = 3
flag = True
for i in range(n):
	a = int(input())
	if a == spec:
		flag = False
	spec = 6 - a - spec
print('YES' if flag else 'NO')


n = int(input())
lst = list()
for i in range(n):
	lst.append(int(input()))
lose = 3 - lst[0]
if lose == 0:
	print('NO')
	exit()
for i in range(1, n):
	if lst[i] == lose:
		print('NO')
		exit()
	else:
		lose = 6 - lst[i] - lose
print('YES')


import sys
n = int(input())
a = list(map(int, sys.stdin))
(x, y, z) = (1, 2, 3)
for won in a:
	if x == won:
		(y, z) = (z, y)
	elif y == won:
		(x, z) = (z, x)
	else:
		print('NO')
		exit()
print('YES')


n = int(input())
a = []
m = 3
s = 0
for i in range(n):
	a.append(int(input()))
	if a[i] == m:
		print('NO')
		break
	else:
		for j in range(1, 4):
			if j != m and j != a[i]:
				m = j
				break
	s += 1
if s == n:
	print('YES')


n = int(input())
cur = 1
can = True
for i in range(n):
	x = int(input())
	if x == 1:
		if cur == 3:
			can = False
		elif cur == 1:
			cur = 2
		elif cur == 2:
			cur = 1
	elif x == 2:
		if cur == 2:
			can = False
		elif cur == 1:
			cur = 3
		elif cur == 3:
			cur = 1
	elif x == 3:
		if cur == 1:
			can = False
		elif cur == 2:
			cur = 3
		elif cur == 3:
			cur = 2
print('YES' if can else 'NO')


n = int(input())
cur_pl = [1, 2]
for i in range(n):
	a = int(input())
	x = a in cur_pl
	if x == 0:
		print('NO')
		break
	elif 3 not in cur_pl:
		cur_pl[cur_pl.index(a) ^ 1] = 3
	elif 2 not in cur_pl:
		cur_pl[cur_pl.index(a) ^ 1] = 2
	elif 1 not in cur_pl:
		cur_pl[cur_pl.index(a) ^ 1] = 1
else:
	print('YES')


ans = 3
flag = False
for i in range(int(input())):
	x = int(input())
	if x == ans:
		print('NO')
		flag = True
		break
	ans = 6 - x - ans
if not flag:
	print('YES')


(n, out) = (int(input()), 1)
(players, spect) = ([1, 2], 3)
while n:
	buf = int(input())
	if buf == spect:
		out = 0
	elif players[0] == buf:
		tmp = players[1]
		players[1] = spect
		spect = tmp
	else:
		tmp = players[0]
		players[0] = spect
		spect = tmp
	n -= 1
if out == 1:
	print('YES')
else:
	print('NO')


def read():
	return [int(v) for v in input().split()]

def main():
	n = read()[0]
	a = []
	for _ in range(n):
		a.append(read()[0])
	(player1, player2, specator) = (1, 2, 3)
	for winner in a:
		if winner == player1:
			(player2, specator) = (specator, player2)
		elif winner == player2:
			(player1, specator) = (specator, player1)
		else:
			print('NO')
			break
	else:
		print('YES')
main()


n = int(input())
a = [int(input()) for _ in range(n)]
ans = 'YES'
s = 3
for ai in a:
	if ai == s:
		ans = 'NO'
		break
	elif (ai + 3 - s) % 3 == 1:
		s = ai % 3 + 1
	else:
		s = (ai + 1) % 3 + 1
print(ans)


T = int(input())
ans = True
g = [1, 2]
s = 3
for _ in range(T):
	w = int(input())
	if w not in g:
		ans = False
		break
	else:
		g.remove(w)
		l = g[0]
		g = [w]
		g.append(s)
		s = l
		ans = True
print('YES' if ans == True else 'NO')


n = int(input())
arr = list()
a = 1
b = 2
c = 3
f = 0
for i in range(n):
	t = int(input())
	arr.append(t)
for i in range(n):
	if arr[i] != a and arr[i] != b:
		print('NO')
		f = 1
		break
	if arr[i] == a:
		b = b + c
		c = b - c
		b = b - c
	elif arr[i] == b:
		a = a + c
		c = a - c
		a = a - c
if f == 0:
	print('YES')


Players = ['1', '2', '3']
playing = ['1', '2']
sittingOut = '3'
n = int(input())
s = True
for i in range(0, n):
	w = str(input())
	if w is sittingOut:
		s = False
	else:
		temp = sittingOut
		if w is playing[0]:
			sittingOut = playing[1]
		elif w is playing[1]:
			sittingOut = playing[0]
		playing = [w]
		playing.append(temp)
if s:
	print('YES')
else:
	print('NO')


n = int(input())
a1 = int(input())
if a1 == 3:
	print('NO')
else:
	l = 3 - a1
	s = 'YES'
	for i in range(1, n):
		w = int(input())
		if w == l:
			s = 'NO'
			break
		p = {1, 2, 3} - {w, l}
		l = p.pop()
	print(s)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
x = 3
f = True
for i in range(n):
	if a[i] == x:
		f = False
		break
	if a[i] == 1 and x == 3 or (a[i] == 3 and x == 1):
		x = 2
	elif a[i] == 1 and x == 2 or (a[i] == 2 and x == 1):
		x = 3
	elif a[i] == 2 and x == 3 or (a[i] == 3 and x == 2):
		x = 1
if f:
	print('YES')
else:
	print('NO')


n = int(input())
p1 = 1
p2 = 2
v = 3
b = True
for i in range(n):
	c = int(input())
	if c == v:
		b = False
		break
	elif c == p1:
		(p2, v) = (v, p2)
	else:
		(p1, v) = (v, p1)
print('YES' if b else 'NO')


t = int(input())
l = []
x = 1
y = 2
z = 3
while t > 0:
	a = int(input())
	if a == z:
		print('NO')
		exit(0)
	if a == x:
		(y, z) = (z, y)
	else:
		(x, z) = (z, x)
	t -= 1
print('YES')


n = int(input())
(a, b) = (1, 2)
c = 3
m = []
for i in range(n):
	m.append(int(input()))
for x in m:
	if x == a:
		(b, c) = (c, b)
	elif x == b:
		(a, c) = (c, a)
	else:
		print('NO')
		break
else:
	print('YES')


n = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
flag = True
(p1, p2) = (1, 2)
for x in a:
	if x != p1 and x != p2:
		flag = False
		break
	elif x == p1:
		p2 = 6 - p1 - p2
	else:
		p1 = 6 - p1 - p2
print('YES' if flag else 'NO')


n = int(input())
l = []
a = [1, 2]
k = 0
for i in range(n):
	m = input()
	if int(m) == int(a[0]):
		k = k
		a.append(6 - int(m) - int(a[1]))
		a.pop(1)
	elif int(m) == int(a[1]):
		k = k
		a.append(6 - int(m) - int(a[0]))
		a.pop(0)
	else:
		k = k + 1
if k == 0:
	print('YES')
else:
	print('NO')


def solve(a):
	e = 3
	x = 1
	y = 2
	for i in a:
		if i == x:
			(y, e) = (e, y)
		elif i == y:
			(x, e) = (e, x)
		else:
			return 'NO'
	return 'YES'

def main():
	a = [int(input()) for _ in range(int(input()))]
	print(solve(a))
main()


n = int(input())
played = [1 for i in range(4)]
played[3] = 0
ans = 'YES'
for i in range(1, n + 1):
	win = int(input())
	if played[win] == 0:
		ans = 'NO'
	else:
		for j in range(1, 4):
			if played[j] == 0:
				played[j] = 1
			elif played[j] == 1 and j != win:
				played[j] = 0
print(ans)


n = int(input())
p1 = 1
p2 = 2
wait = 3
for i in range(n):
	x = int(input())
	if x == wait:
		print('NO')
		quit()
	if x == p1:
		(wait, p2) = (p2, wait)
	elif x == p2:
		(wait, p1) = (p1, wait)
print('YES')


n = int(input())
opponent = 3
for i in range(n):
	winner = int(input())
	if winner == opponent:
		print('NO')
		exit()
	opponent = 6 - winner - opponent
print('YES')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
lst = [get_int() for _ in range(n)]
state = 1
win = [0] * 3
valid = True
for i in range(n):
	if state == 1:
		if lst[i] == 1:
			state = 3
		elif lst[i] == 2:
			state = 2
		else:
			valid = False
			break
	elif state == 2:
		if lst[i] == 2:
			state = 1
		elif lst[i] == 3:
			state = 3
		else:
			valid = False
			break
	elif lst[i] == 1:
		state = 1
	elif lst[i] == 3:
		state = 2
	else:
		valid = False
		break
if valid:
	print('YES')
else:
	print('NO')


def solve():
	n = int(input())
	players = [1, 2]
	for _ in range(n):
		p = int(input())
		if p not in players:
			return 'NO'
		players = [p, 6 - sum(players)]
	return 'YES'
print(solve())


n = int(input())
a = [1, 2]
c = []
for i in range(n):
	c.append(int(input()))
for i in range(n):
	l = c[i]
	if l in a:
		b = []
		b.append(l)
		for j in range(1, 4):
			if not j in a:
				b.append(j)
		a = b
	else:
		print('NO')
		exit()
print('YES')


t = int(input())
playing = [1, 2]
watching = 3
out = 'YES'
for i in range(t):
	x = int(input())
	if x not in playing:
		out = 'NO'
		break
	for e in playing:
		if e != x:
			y = e
	playing.remove(y)
	playing.append(watching)
	watching = y
print(out)


n = int(input())
spec = 3
l = []
for i in range(n):
	x = int(input())
	l.append(x)
ans = 'YES'
poss = [1, 2]
spec = 3
for i in l:
	if i not in poss:
		ans = 'NO'
		break
	else:
		poss.append(spec)
		for j in poss:
			if j != spec and j != i:
				spec = j
				break
		poss.remove(spec)
print(ans)


def solution(games):
	current_players = [True, True, False]
	for winner in games:
		if not current_players[winner - 1]:
			return False
		current_players = [True if winner - 1 == player else not current_players[player] for player in range(3)]
	return True
n = int(input())
games = [int(input()) for i in range(n)]
print('YES' if solution(games) else 'NO')


n = int(input())
a = []
k = 0
for i in range(n):
	a.append(int(input()))
o = [3, 1, 2]
f = 0
for j in range(n):
	if a[j] == o[1]:
		f = o[2]
		o[2] = o[0]
		o[0] = f
	elif a[j] == o[2]:
		f = o[1]
		o[1] = o[0]
		o[0] = f
	elif a[j] == o[0]:
		k = 1
		break
if k == 1:
	print('NO')
else:
	print('YES')


def fun(arr):
	if arr[0] == 3:
		print('NO')
		return
	if arr[0] == 1:
		lost = 2
	else:
		lost = 1
	for i in range(1, len(arr)):
		if arr[i] == lost:
			print('NO')
			return
		if arr[i - 1] != arr[i]:
			lost = arr[i - 1]
		if arr[i - 1] == arr[i]:
			lost = 6 - lost - arr[i]
	print('YES')
	return
arr = []
for i in range(0, int(input())):
	n = int(input())
	arr.append(n)
fun(arr)


n = int(input())
p1 = 1
p2 = 2
p3 = 3
for i in range(n):
	k = int(input())
	if p1 != k and p2 != k:
		print('NO')
		break
	elif k == p1:
		(p2, p3) = (p3, p2)
	else:
		(p1, p3) = (p3, p1)
else:
	print('YES')


n = int(input())
player = [1, 2, 3]
correct = 0
spec = 3
for i in range(n):
	won = int(input())
	if won == spec:
		correct = 1
	for play in player:
		if play != spec and play != won:
			spec = play
			break
if correct == 1:
	print('NO')
else:
	print('YES')


def main():
	x = eval(input())
	check = True
	list1 = [True, True, True, False]
	for i in range(x):
		win = eval(input())
		if list1[win] == False:
			check = False
			continue
		for j in [1, 2, 3]:
			if win != j and list1[j] == list1[win]:
				lose = j
		for j in [1, 2, 3]:
			if j != win and j != lose:
				list1[j] = True
		list1[lose] = False
	if check:
		print('YES')
	else:
		print('NO')
main()


N = int(input())
L = []
for k in range(N):
	L.append(int(input()))
W1 = 1
W2 = 2
FLAG = 0
for i in range(N):
	if L[i] == W1 or L[i] == W2:
		for j in range(1, 4):
			if j != W1 and j != W2:
				W2 = j
				W1 = L[i]
				break
	else:
		FLAG = 1
		print('NO')
		break
if FLAG == 0:
	print('YES')


n = int(input())
l = []
l = list(map(int, (input() for _ in range(n))))
status = True
left_out = 3
current = [1, 2]
for i in l:
	if i not in current:
		status = False
		break
	current.remove(i)
	tmp = current.pop()
	current = [left_out, i]
	left_out = tmp
if status:
	print('YES')
else:
	print('NO')


def main():
	(x, y) = (1, 2)
	for _ in range(int(input())):
		z = int(input())
		if x != z != y:
			print('NO')
			return
		(x, y) = (z, 6 - x - y)
	print('YES')
main()