qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main(s,end,start,perse):
    start.reverse()
    start.append(''.join(s))
    start.append(''.join(end))
    print(start)
    print(''.join(start))
def conv(s):
    a = []
    for i in range(len(s)):
        a.append(s[i])
    return a
perse = 1
start = []
end = []
  
s = input()
q = int(input())
for i in range(q):
    query = input().split()
    query[0] = int(query[0])
    if query[0] == 1:
        perse = -perse
    else:
        query[1] = int(query[1])
        if (int(query[1])*2-3)*perse == 1:
            end.append(query[2])
        else:
            start.append(query[2])
s =  conv(s)
if perse == -1:
    start.reverse()
    s.reverse()
    end.reverse()
main(s,end,start,perse)

Fixed code:
def main(s,end,start,perse):
    start.reverse()
    start.append(''.join(s))
    start.append(''.join(end))
    if perse == -1:
        start.reverse()
    print(''.join(start))
def conv(s):
    a = []
    for i in range(len(s)):
        a.append(s[i])
    return a
perse = 1
start = []
end = []
  
s = input()
q = int(input())
for i in range(q):
    query = input().split()
    query[0] = int(query[0])
    if query[0] == 1:
        perse = -perse
    else:
        query[1] = int(query[1])
        if (int(query[1])*2-3)*perse == 1:
            end.append(query[2])
        else:
            start.append(query[2])
s =  conv(s)
if perse == -1:
    s.reverse()
    end.reverse()
main(s,end,start,perse)
Buggy code:
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
l = r = ""
for op in qs:
    if op[0] == '1':
        n = not n
    if op[0] == '2':
        t , f, c = op
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f != 1:
            l=c+l
        elif f == 2:
            r+=c
s = l+s+r
print(s[::-1] if n else s)

Fixed code:
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
l = r = ""
for op in qs:
    if op[0] == '1':
        n = not n
    if op[0] == '2':
        t , f, c = op
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            l=c+l
        elif f == 2:
            r+=c
s = l+s+r
print(s[::-1] if n else s)
Buggy code:
import sys
S = input()
Q = int(input())
key = 1

for i in sys.stdin:
    if i[0] == '0':
        break

    if i[0] == '1':
        key = -key
    
    if key == 1:
        if i[2] == '1':
            S = i[4] + S
        else:
            S = S + i[4]

    else:
        if i[2] == '2':
            S = i[4] + S
        else:
            S = S + i[4]


print(S[::key])


Fixed code:
import sys
S = input()
Q = int(input())
key = 1

for i in sys.stdin:
    if i[0] == '0':
        break

    if i[0] == '1':
        key = -key
    
    elif key == 1:
        if i[2] == '1':
            S = i[4] + S
        else:
            S = S + i[4]

    else:
        if i[2] == '2':
            S = i[4] + S
        else:
            S = S + i[4]


print(S[::key])
Buggy code:
#!/usr/bin/env python3
s = input()
Q = int(input())
q = [input().split() for _ in range(Q)]
reverse = 0
start = ""
end = ""
for i in q:
    if i[0] == "1":
        reverse ^= 1
    else:
        if int(i[1]) + reverse >> 0 ^ 0:
            end += i[2]
        else:
            start += i[2]
s = start[::-1] + s + end
print(s[::1 - reverse * 2])


Fixed code:
#!/usr/bin/env python3
s = input()
Q = int(input())
q = [input().split() for _ in range(Q)]
reverse = 0
start = ""
end = ""
for i in q:
    if i[0] == "1":
        reverse ^= 1
    else:
        if (int(i[1]) + reverse) % 2:
            start += i[2]
        else:
            end += i[2]
s = start[::-1] + s + end
print(s[::1 - reverse * 2])
Buggy code:
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                front = [q[-1]] + front
            else:
                back = back + [q[-1]]
        else:
            if q[2] == '1':
                back = back + [q[-1]]
            else:
                front = [q[-1]] + front
                
s = ''.join(front) + s + ''.join(back)
# if flg % 2 == 1:
#     s = s[::-1]
print(s)

Fixed code:
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                #front = [q[-1]] + front
                front.append(q[-1])
            else:
                #back = back + [q[-1]]
                back.append(q[-1])
        else:
            if q[2] == '1':
                #back = back + [q[-1]]
                back.append(q[-1])
            else:
                #front = [q[-1]] + front
                front.append(q[-1])
                

if flg % 2 == 1:
    s = ''.join(back)[::-1] + s[::-1] + ''.join(front)
else:
    s = ''.join(front)[::-1] + s + ''.join(back)
print(s)
Buggy code:
from sys import stdin
 
def main():
    S = list(stdin.readline().rstrip())
    Q = int(input())
    rev = 0
    head = []
    tail = []
 
    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    head.append(q[4])
                else:
                    tail.append(q[4])
            else:
                if rev ==0:
                    tail.append(q[4])
                else:
                    head.append(q[4])
 
    if rev == 0:
        ans = "".join(head[::-1] + S + tail)
    else:
        ans = "".join(tail[::-1] + S[::-1] + head)
    
    print(ans)

Fixed code:
from sys import stdin
 
def main():
    S = list(stdin.readline().rstrip())
    Q = int(input())
    rev = 0
    head = []
    tail = []
 
    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    head.append(q[4])
                else:
                    tail.append(q[4])
            else:
                if rev ==0:
                    tail.append(q[4])
                else:
                    head.append(q[4])
 
    if rev == 0:
        ans = "".join(head[::-1] + S + tail)
    else:
        ans = "".join(tail[::-1] + S[::-1] + head)
    
    print(ans)
    
main()
Buggy code:
import numpy as np
import sys

input = sys.stdin.readline

S = input()
Q = int(input())

left = []
right = []
rev = False
for i in range(Q):
    l = input().split()
    if l[0] == '1':
        rev = not rev
    else:
        if ( l[1] == '1' and not rev) or (l[1] == '2' and rev):
            left.append(l[2])
        else:
            right.append(l[2])

S = ''.join(left[::-1]) + S + ''.join(right)

if rev:
    print(S[::-1])
else:
    print(S)

Fixed code:
import numpy as np
import sys

input = sys.stdin.readline

S = input()
Q = int(input())

left = []
right = []
rev = False

for i in range(Q):
    l = input().split()
    if l[0] == '1':
        rev = not rev
    else:
        if (l[1] == '1' and not rev) or (l[1] == '2' and rev):
            left.append(l[2])
        else:
            right.append(l[2])

S = ''.join(left[::-1]) + S + ''.join(right)

if rev:
    print(S[::-1].replace('\n',''))
else:
    print(S.replace('\n',''))
Buggy code:
s=[input()]
q=int(input())
turn=True
l=""
for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn and int(qq[1])-2:
            l+=qq[2]
        else:
            s.append(qq[2])

text=l+"".join(s)
print(text if turn else text[::-1])

Fixed code:
s=[input()]
q=int(input())
turn=True
l=""
for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn==bool(int(qq[1])-2):
            l+=qq[2]
        else:
            s.append(qq[2])

text=l[::-1]+"".join(s)
print(text if turn else text[::-1])
Buggy code:
s=input()
q=int(input())
from collections import deque
qq=deque(s)
cnt=0
for i in range(q):
    j=input()
    if j=="1":
        cnt+=1
        continue
    _,k,l=j.split()
    if (k=="2")^cnt%2:
        qq.append(l)
    else:
        qq.appendleft(l)

if cnt%2==1:
    print("".join(revesed(list(qq))))
else:
    print("".join(qq))

Fixed code:
s=input()
q=int(input())
from collections import deque
qq=deque(s)
cnt=0
for i in range(q):
    j=input()
    if j=="1":
        cnt+=1
        continue
    _,k,l=j.split()
    if (k=="2")^cnt%2:
        qq.append(l)
    else:
        qq.appendleft(l)

if cnt%2==1:
    print("".join(reversed(list(qq))))
else:
    print("".join(qq))
Buggy code:
# D
S = input()
Q = int(input())

forward_flag = 1
for i in range(Q):
    n = list(map(str, input().split()))
#     print(n)
    
    if len(n)==1:
        if forward_flag==1:
            forward_flag = 0
        else:
            forward_flag = 1
    else:
        a, b, c = n
        if (forward_flag==1 and b=="1") or (forward_flag==0 and b=="2"):
            S=c+S
        else:
            S=S+c
#     if forward_flag==1:
#         print(S)
#     else:
#         print(S[::-1])
print(S)


Fixed code:
# D
S = input()
Q = int(input())

forward_flag = 1

front = ""
back = ""

for i in range(Q):
    n = list(map(str, input().split()))
#     print(n)
    
    if len(n)==1:
        if forward_flag==1:
            forward_flag = 0
        else:
            forward_flag = 1
    else:
        a, b, c = n
        if (forward_flag==1 and b=="1") or (forward_flag==0 and b=="2"):
            front += c
        else:
            back += c

if forward_flag==1:
    print(front[::-1], end="")
    print(S, end="")
    print(back)
else:
    print(back[::-1], end="")
    print(S[::-1], end="")
    print(front)
Buggy code:
S = input()
NQ = int(input())

reverseFlag = False

for i in range(NQ):
    query = input().split()
    if (int(query[0]) == 1):
        reverseFlag = not reverseFlag
    else:
        if (reverseFlag):
            if (int(query[1]) == 1):
                S = query[2] + S
            else:
                S = S + query[2]
        else:
            if (int(query[1]) == 1):
                S = S + query[2]
            else:
                S = query[2] + S

if (reverseFlag):
    print(S[::-1])
else:
    print(S)



Fixed code:
S = input()
NQ = int(input())

reverseFlag = False
prefix = ""
suffix = ""

for i in range(NQ):
    query = input().split()
    if (int(query[0]) == 1):
        reverseFlag = not reverseFlag
    else:
        if (reverseFlag):
            if (int(query[1]) == 1):
                suffix = suffix + query[2]
            else:
                prefix = query[2] + prefix
        else:
            if (int(query[1]) == 1):
                prefix = query[2] + prefix
            else:
                suffix = suffix + query[2]

if (reverseFlag):
    print(suffix[::-1] + S[::-1] + prefix[::-1])
else:
    print(prefix + S + suffix)
Buggy code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input())
cnt = 0
for i in range(Q):
    q = list(input().split())
    if len(q)==1:
        cnt += 1
    else:
        F = int(q[1])
        C = q[2]
        if cnt%2==0:
            if F==1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F==1:
                S.append(C)
            else:
                S.appendleft(C)
if cnt%2==0:
    print("".join(S))
else:
    S = S[::-1]
    print("".join(S))

Fixed code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input())
cnt = 0
for i in range(Q):
    q = list(input().split())
    if len(q)==1:
        cnt += 1
    else:
        F = int(q[1])
        C = q[2]
        if cnt%2==0:
            if F==1:
                S.appendleft(C)
            else:
                S.append(C)
        else:
            if F==1:
                S.append(C)
            else:
                S.appendleft(C)
if cnt%2==0:
    print("".join(S))
else:
    S = list(S)[::-1]
    print("".join(S))
Buggy code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input().strip())
flag = 1
for i in range(Q):
  line = input().strip()
  if len(line) == 1:
    flag = 1 - flag
  else:
    _, F, C = line.strip().split()
    if flag:
      if int(F) == 1:
        S.appendleft(C)
      else:
        S.append(C)
    else:
      if int(F) == 1:
        S.append(C)
      else:
        S.appendleft(C)

if flag:
  print(''.join(S))
else:
  print(''.join(S[::-1]))
    

Fixed code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input().strip())
flag = 1
for i in range(Q):
  line = input().strip()
  if len(line) == 1:
    flag = 1 - flag
  else:
    _, F, C = line.strip().split()
    if flag:
      if int(F) == 1:
        S.appendleft(C)
      else:
        S.append(C)
    else:
      if int(F) == 1:
        S.append(C)
      else:
        S.appendleft(C)

if flag:
  print(''.join(S))
else:
  print(''.join(list(reversed(S))))
Buggy code:
s=input()
q=int(input())
i=0
for _ in range(q):
    a=list(input().split())
    if a[0]=="1":
        i+=1
    else:
        if a[1]=="1" and i%2==1:
            z=z+a[3]
        elif a[1]=="1" and i%2==0:     
            x=a[2]+x
        elif a[1]=="2" and i%2==1:  
            x=x+a[3]
        else:
            z=z+a[3]
print(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)

Fixed code:
s=input()
q=int(input())
i=0
x=z=""
for _ in range(q):
    a=list(input().split())
    if a[0]=="1":
        i+=1
    else:
        if a[1]=="1" and i%2==1:
            z=z+a[2]
        elif a[1]=="1" and i%2==0:     
            x=a[2]+x
        elif a[1]=="2" and i%2==1:  
            x=a[2]+x
        else:
            z=z+a[2]
print(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)
Buggy code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input())
cnt = 0
for _ in range(Q):
    q = list(input().split())
    if int(q[0])==1:
        cnt += 1
    else:
        if cnt%2==0:
            if int(q[1])==1:
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if int(q[1])==1:
                S.append(q[2])
            else:
                S.appendleft(q[2])
if cnt%2==0:
    print("".join(S))
else:
    S = S[::-1]
    print("".join(S))

Fixed code:
from collections import deque
S = deque(list(input().strip()))
Q = int(input())
cnt = 0
for _ in range(Q):
    q = list(input().split())
    if int(q[0])==1:
        cnt += 1
    else:
        if cnt%2==0:
            if int(q[1])==1:
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if int(q[1])==1:
                S.append(q[2])
            else:
                S.appendleft(q[2])
if cnt%2==0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))
Buggy code:
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if sum(A[0][i])==0 or sum(A[1][i])==0 or sum(A[2][i])==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")
print(sum(A[:][1]))
print(sum(A[1][:]))
print(bingo)

Fixed code:
B=[];bingo=0
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
#print(A)
for i in range(3):
  if sum(A[i][:])==0:
    bingo=bingo+1
for i in range(3):
  if A[0][i]+A[1][i]+A[2][i]==0:
    bingo=bingo+1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=bingo+1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=bingo+1
print("Yes" if bingo>=1 else "No")
Buggy code:
import numpy as np

data = np.array([input().split() for i in range(3)])
data = data.astype(np.int64)

N = int(input())

ans = 0
for i in range(N):
	check = 0
	num = int(input())
	for x in range(3):
		for y in range(3):
			if num == data[x][y]:
				data[x][y] = -1
				break
		if check == 1:
			break

if data[0][0] == -1 and data[0][1] == -1 and data[0][2] == -1:
	print("Yes")
elif data[1][0] == -1 and data[1][1] == -1 and data[1][2] == -1:
	print("Yes")
elif data[2][0] == -1 and data[2][1] == -1 and data[2][2] == -1:
	print("Yes")
if data[0][0] == -1 and data[1][0] == -1 and data[2][0] == -1:
	print("Yes")
elif data[0][1] == -1 and data[1][1] == -1 and data[2][1] == -1:
	print("Yes")
elif data[0][2] == -1 and data[1][2] == -1 and data[2][2] == -1:
	print("Yes")
elif data[0][0] == -1 and data[1][1] == -1 and data[2][2] == -1:
	print("Yes")
elif data[0][2] == -1 and data[1][1] == -1 and data[2][0] == -1:
	print("Yes")
else:
	print("No")

Fixed code:
import numpy as np

data = np.array([input().split() for i in range(3)])
data = data.astype(np.int64)

N = int(input())

ans = 0
for i in range(N):
	check = 0
	num = int(input())
	for x in range(3):
		for y in range(3):
			if num == data[x][y]:
				data[x][y] = -1
				break
		if check == 1:
			break

if data[0][0] == -1 and data[0][1] == -1 and data[0][2] == -1:
	ans = 1
elif data[1][0] == -1 and data[1][1] == -1 and data[1][2] == -1:
	ans = 1
elif data[2][0] == -1 and data[2][1] == -1 and data[2][2] == -1:
	ans = 1
if data[0][0] == -1 and data[1][0] == -1 and data[2][0] == -1:
	ans = 1
elif data[0][1] == -1 and data[1][1] == -1 and data[2][1] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][2] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][0] == -1 and data[1][1] == -1 and data[2][2] == -1:
	ans = 1
elif data[0][2] == -1 and data[1][1] == -1 and data[2][0] == -1:
	ans = 1

if ans == 1:
	print("Yes")
else:
	print("No")
Buggy code:
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                print(cross_2)
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans=0
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)
    
    


Fixed code:
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
b=[int(input()) for _ in range(N)]

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans="Yes"
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)
Buggy code:
def solve():
    card = []
    num_pos = {}
    for i in range(3):
        row = [int(num) for num in input().split()]
        card.append(row)
        for j,num in enumerate(row):
            num_pos[num] = (i,j)

    N = int(input())
    for i in range(N):
        target = int(input())
        # print(int(input()))
        if target in num_pos:
            pos_i, pos_j = num_pos[target]
            card[pos_i][pos_j] = 0

    ans = False
    for row in card:
        if not any(row):
            ans = True
    for column in range(3):
        column_flag = True
        for i in range(3):
            if card[i][column]:
                column_flag = False
        if column_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[2-i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")

    print(card)

if __name__ == "__main__":
    solve()

Fixed code:
def solve():
    card = []
    num_pos = {}
    for i in range(3):
        row = [int(num) for num in input().split()]
        card.append(row)
        for j,num in enumerate(row):
            num_pos[num] = (i,j)

    N = int(input())
    for i in range(N):
        target = int(input())
        # print(int(input()))
        if target in num_pos:
            pos_i, pos_j = num_pos[target]
            card[pos_i][pos_j] = 0

    ans = False
    for row in card:
        if not any(row):
            ans = True
    for column in range(3):
        column_flag = True
        for i in range(3):
            if card[i][column]:
                column_flag = False
        if column_flag:
            ans = True
    diagonal_flag = True
    for i in range(3):
        if card[i][i]:
            diagonal_flag = False
    if diagonal_flag:
        ans = True
    diagonal_flag = True
    for i in range(3):
        if card[2-i][i]:
            diagonal_flag = False
    if diagonal_flag:
        ans = True
    if ans:
        print("Yes")
    else:
        print("No")
    # for row in card:
    #     print(row)

if __name__ == "__main__":
    solve()
Buggy code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
num_count = int(input())
number_list = [0] * num_count
for i in range(num_count):
    number_list[i] = int(input())

bingo_map = [[a, b, c], [d, e, f], [g, h, i]]
bingo_answer = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def bingo(bingo_map, number_list):
    for number in number_list:
        for i, bingo_row in enumerate(bingo_map):
            if number in bingo_row:
                for j, bingo_number in enumerate(bingo_row):
                    if bingo_number == number:
                        bingo_answer[i][j] = 1


def check_bingo():
    return (all(bingo_answer[0]) or all(bingo_answer[1]) or all(bingo_answer[2]) or
    all(bingo_answer[0][0], bingo_answer[1][0], bingo_answer[2][0]) or
    all(bingo_answer[0][1], bingo_answer[1][1], bingo_answer[2][1]) or
    all(bingo_answer[0][2], bingo_answer[1][2], bingo_answer[2][2]) or
    all(bingo_answer[0][0], bingo_answer[1][1], bingo_answer[2][2]) or
    all(bingo_answer[2][0], bingo_answer[1][1], bingo_answer[0][2]))

bingo(bingo_map, number_list)

if check_bingo():
    print "Yes"
else:
    print "No"


Fixed code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, x = map(int, input().split())
num_count = int(input())
number_list = [0] * num_count
for i in range(num_count):
    number_list[i] = int(input())

bingo_map = [[a, b, c], [d, e, f], [g, h, x]]
bingo_answer = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def bingo(bingo_map, number_list):
    for number in number_list:
        for i, bingo_row in enumerate(bingo_map):
            if number in bingo_row:
                for j, bingo_number in enumerate(bingo_row):
                    if bingo_number == number:
                        bingo_answer[i][j] = 1


def check_bingo():
    return (all(bingo_answer[0]) or all(bingo_answer[1]) or all(bingo_answer[2]) or
    all([bingo_answer[0][0], bingo_answer[1][0], bingo_answer[2][0]]) or
    all([bingo_answer[0][1], bingo_answer[1][1], bingo_answer[2][1]]) or
    all([bingo_answer[0][2], bingo_answer[1][2], bingo_answer[2][2]]) or
    all([bingo_answer[0][0], bingo_answer[1][1], bingo_answer[2][2]]) or
    all([bingo_answer[2][0], bingo_answer[1][1], bingo_answer[0][2]]))

bingo(bingo_map, number_list)

if (check_bingo()):
    print("Yes")
else:
    print("No")