AtCoder Beginner Contest 179 - Go to Jail

Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.

-----Constraints-----
 - 3 \leq N \leq 100
 - 1\leq D_{i,j} \leq 6
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}

-----Output-----
Print Yes if doublets occurred at least three times in a row. Print No otherwise.

-----Sample Input-----
5
1 2
6 6
4 4
3 3
3 2

-----Sample Output-----
Yes

From the second roll to the fourth roll, three doublets occurred in a row.

Difficulty: EASY

Starter code:

Solutions:
num = input()
cnt = 0
for _ in range(int(num)):
	a = input()
	b = list(a)
	if b[0] == b[2]:
		cnt += 1
		if cnt >= 3:
			print('Yes')
			break
	else:
		cnt = 0
if cnt <= 2:
	print('No')


N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for (d1, d2) in D:
	if d1 != d2:
		cnt = 0
		continue
	cnt += 1
	if cnt >= 3:
		print('Yes')
		break
else:
	print('No')


N = int(input())
count = 0
ans = 'No'
for _ in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		count += 1
	else:
		count = 0
	if count == 3:
		ans = 'Yes'
print(ans)


c = 0
for _ in range(int(input())):
	(d, _, e) = input()
	if d == e:
		c += 1
	else:
		c = 0
	if c > 2:
		exit(print('Yes'))
print('No')


N = int(input())
x = ''.join(map(str, [len(set(input().split())) for _ in range(N)]))
if '111' in x:
	print('Yes')
else:
	print('No')


N = int(input())
count = 0
for i in range(N):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		count += 1
	else:
		count = 0
	if count == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
dice = []
for _ in range(N):
	dice.append(list(map(int, input().split())))
check = 3
for n in range(N):
	if dice[n][0] == dice[n][1]:
		check -= 1
		if check == 0:
			print('Yes')
			return
	else:
		check = 3
print('No')


N = int(input())
(curr, prev, twice, thrice) = (False, False, False, False)
for i in range(0, N):
	row = input()
	curr = row[0] == row[2]
	thrice = thrice or (twice and curr)
	twice = curr and prev
	prev = curr
if thrice:
	print('Yes')
else:
	print('No')


n = int(input())
lst = [input() for _ in range(n)]
x = 0
for i in range(n):
	if x != 3:
		if x == 0 and lst[i][0] == lst[i][2]:
			x = 1
		elif x != 0 and lst[i][0] == lst[i][2]:
			x += 1
		elif x != 0 and lst[i][0] != lst[i][2]:
			x = 0
if x >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
cnt = 0
ans = 'No'
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		cnt += 1
		if cnt == 3:
			ans = 'Yes'
	else:
		cnt = 0
print(ans)


N = int(input())
key = 0
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		key += 1
	else:
		key = 0
	if key == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
cnt = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit(0)
print('No')


n = int(input())
cnt = 0
ans = 'No'
for i in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		cnt += 1
	else:
		cnt = 0
	if cnt >= 3:
		ans = 'Yes'
print(ans)


n = int(input())
a = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		a += 1
	else:
		a = 0
	if a == 3:
		print('Yes')
		exit(0)
print('No')


n = int(input())
c = 0
for i in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		c += 1
	else:
		c = 0
	if c == 3:
		print('Yes')
		break
else:
	print('No')


n = int(input())
cnt = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
count = 0
for i in range(n - 2):
	if a[i] == b[i] and a[i + 1] == b[i + 1] and (a[i + 2] == b[i + 2]):
		count += 1
if count != 0:
	print('Yes')
else:
	print('No')


n = int(input())
c = 0
r = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
		if c == 3:
			print('Yes')
			return
	else:
		c = 0
print('No')


n = int(input())
j = ''
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		j += 't'
	else:
		j += 'f'
print('Yes' if 'ttt' in j else 'No')


N = int(input())
f = 0
for _ in range(N):
	D = input().split()
	if D[0] == D[1]:
		f += 1
	else:
		f = 0
	if f == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
doubles = 0
jail = False
for i in range(n):
	dice = input().split()
	if dice[0] == dice[1]:
		doubles += 1
	else:
		doubles = 0
	if doubles == 3:
		jail = True
		print('Yes')
if not jail:
	print('No')


ng = True
cnt = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		cnt += 1
	else:
		cnt = 0
	if cnt >= 3:
		ng = False
print('YNeos'[ng::2])


import sys
n = int(input())
l = []
c = 0
for x in range(n):
	l.append(list(map(int, input().split())))
	if l[x][0] == l[x][1]:
		c += 1
		if c == 3:
			print('Yes')
			return
	else:
		c = 0
print('No')


n = int(input())
c = 0
for i in range(n):
	(d, e) = map(int, input().split())
	if d == e:
		c += 1
		if c == 3:
			print('Yes')
			break
	else:
		c = 0
else:
	print('No')


N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
(x, y) = [list(i) for i in zip(*xy)]
count = 0
for i in range(N - 2):
	if x[i] == y[i] and x[i + 1] == y[i + 1] and (x[i + 2] == y[i + 2]):
		print('Yes')
		count = 1
		break
if count == 0:
	print('No')


n = int(input())
s = 0
for i in range(n):
	if s == 3:
		break
	(a, b) = map(int, input().split())
	if a == b:
		s += 1
	else:
		s = 0
print('Yes' if s >= 3 else 'No')


n = int(input())
m = 0
x = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		x += 1
	else:
		x = 0
	m = max(x, m)
if m >= 3:
	print('Yes')
else:
	print('No')


N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
print('Yes' if 'True, True, True' in str([d[0] == d[1] for d in D]) else 'No')


testcases = int(input())
count = 0
bool = False
for i in range(testcases):
	a = input()
	if a[0] == a[-1]:
		count += 1
		if count == 3:
			print('Yes')
			bool = True
			break
	else:
		count = 0
if not bool:
	print('No')


print('NYoe s'['111' in ''.join([str(len(set(input().split()))) for l in range(int(input()))])::2])


n = int(input())
s = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		s += 1
		if s == 3:
			print('Yes')
			quit()
	else:
		s = 0
print('No')


N = int(input())
p = False
s = 0
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		s += 1
		if s == 3:
			p = True
			break
	else:
		s = 0
print('Yes' if p else 'No')


N = int(input())
zolo = 0
for _ in range(N):
	(d1, d2) = list(map(int, input().split()))
	if zolo >= 3:
		continue
	elif d1 == d2:
		zolo += 1
	else:
		zolo = 0
if zolo >= 3:
	print('Yes')
else:
	print('No')


def tripleDoubles(N):
	last_sets = []
	for i in range(0, N):
		values = input().split(' ')
		last_sets.append(values)
		if len(last_sets) >= 3:
			doublesCounter = 0
			for item in last_sets[-3:]:
				if item[0] == item[1]:
					doublesCounter += 1
			if doublesCounter == 3:
				return True
	return False
N = int(input())
print('Yes' if tripleDoubles(N) else 'No')


N = int(input())
cnt = 0
flg = 'No'
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		cnt += 1
		if cnt == 3:
			flg = 'Yes'
			break
	else:
		cnt = 0
print(flg)


a = [len(set(input().split())) == 1 for _ in range(int(input()))]
print('NYoe s'[any(map(all, zip(a, a[1:], a[2:])))::2])


N = int(input())
count = 0
ans = 'No'
while N > 0:
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		count += 1
		if count == 3:
			ans = 'Yes'
	else:
		count = 0
	N -= 1
print(ans)


n = int(input())
dl = []
ans = 0
f = 0
for _ in range(n):
	din = list(map(int, input().split()))
	dl.append([din[0], din[1]])
for i in range(n - 2):
	if dl[i][0] == dl[i][1] and dl[i + 1][0] == dl[i + 1][1] and (dl[i + 2][0] == dl[i + 2][1]):
		f = 1
		break
if f == 1:
	print('Yes')
else:
	print('No')


n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
c = 0
for x in a:
	if x[0] == x[1]:
		c += 1
		if c >= 3:
			print('Yes')
			exit()
	else:
		c = 0
print('No')


print('Yes' if 'TTT' in ''.join(['T' if p else 'F' for p in [len(list(set(list(map(int, input().split()))))) == 1 for l in range(int(input()))]]) else 'No')


N = int(input())
cnt = 0
ans = 'No'
for _ in range(N):
	D = input().split()
	cnt = (cnt + 1) * (D[0] == D[1])
	if cnt == 3:
		ans = 'Yes'
print(ans)


N = int(input())
table = [[int(i) for i in input().split()] for _ in range(N)]
cnt = 0
for i in range(N):
	if table[i][0] == table[i][1]:
		cnt += 1
		if cnt == 3:
			print('Yes')
			return
	else:
		cnt = 0
print('No')


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	result = False
	count = 0
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		if a == b:
			count += 1
		else:
			count = 0
		if count > 2:
			result = True
	print('Yes' if result else 'No')

def __starting_point():
	main()
__starting_point()


N = int(input())
now = 0
ans = 'No'
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		now += 1
	else:
		now = 0
	if now == 3:
		ans = 'Yes'
		break
print(ans)


n = int(input())
zoro = 0
for i in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		zoro += 1
	else:
		zoro = 0
	if zoro == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
D = []
ans = 'No'
for i in range(N):
	(x, y) = list(map(int, input().split()))
	if x == y:
		D.append(1)
	else:
		D.append(0)
for i in range(N - 2):
	if D[i] == D[i + 1] == D[i + 2] == 1:
		ans = 'Yes'
print(ans)


s = int(input())
count = 0
for i in range(s):
	(a, b) = input().split()
	if a == b:
		count += 1
	else:
		count = 0
	if count == 3:
		print('Yes')
		exit()
print('No')


d = []
num = int(input())
for i in range(num):
	s = input()
	d.append(s.split())
try_count = 0
zorome_count = 0
temp = 0
result = 'No'
for i in range(num):
	if d[i][0] == d[i][1]:
		zorome_count += 1
		if i - temp == 1 and zorome_count >= 3:
			result = 'Yes'
			break
		temp = i
	else:
		zorome_count = 0
print(result)


num = int(input())
flg_same = False
count = 0
for i in range(num):
	temp = input().split(' ')
	if temp[0] == temp[1]:
		flg_same = True
	else:
		flg_same = False
	if flg_same:
		count += 1
		if count == 3:
			break
	else:
		count = 0
if count == 3:
	print('Yes')
else:
	print('No')


n = int(input())
s = 'aaa'
for i in range(n):
	(d1, d2) = map(int, input().split(' '))
	if d1 == d2:
		s += 'b'
	else:
		s += 'c'
if 'bbb' in s:
	print('Yes')
else:
	print('No')


s = int(input())
k = 0
co = False
for i in range(s):
	(a, b) = map(int, input().split())
	if a == b:
		k += 1
	else:
		k = 0
	if k >= 3:
		co = True
if co:
	print('Yes')
else:
	print('No')


n = int(input())
ans = 0
flg = 0
aa = 'No'
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		ans += 1
	else:
		ans = 0
	if ans == 3:
		aa = 'Yes'
print(aa)


n = int(input())
s = 0
ok = 0
for i in range(n):
	lis = input().split()
	if lis[0] == lis[1]:
		s += 1
		if s >= 3:
			ok = 1
	else:
		s = 0
if ok == 1:
	print('Yes')
else:
	print('No')


N = int(input())
ans = 0
cnt = 0
for i in range(N):
	(a, b) = input().split()
	if a == b:
		cnt += 1
	else:
		cnt = 0
	ans = max(ans, cnt)
if ans >= 3:
	print('Yes')
else:
	print('No')


N = int(input())
cnt = 0
ans = 'No'
for i in range(N):
	(x, y) = input().split()
	if x == y:
		cnt = cnt + 1
	else:
		cnt = 0
	if cnt >= 3:
		ans = 'Yes'
print(ans)


N = int(input())
count = 0
flag = 0
for i in range(N):
	(a, b) = list(map(int, input().split()))
	if a == b:
		count += 1
	else:
		count = 0
	if count == 3:
		flag = 1
if flag == 1:
	print('Yes')
else:
	print('No')


import sys
n = int(input())
val = 0
for i in range(n):
	(o, t) = map(int, input().split())
	if o == t:
		val += 1
	else:
		val = 0
	if val == 3:
		print('Yes')
		sys.exit()
print('No')


n = int(input())
f = lambda : map(int, input().split())
c = 0
for i in range(n):
	(d, e) = f()
	if d == e:
		c += 1
	else:
		c = 0
	if c == 3:
		exit(print('Yes'))
print('No')


n = int(input())
count = 0
for i in range(n):
	(A, B) = map(int, input().split())
	if A == B:
		count += 1
		if count >= 3:
			print('Yes')
			return
	else:
		count = 0
print('No')


(N, *D) = open(0)
print('YNeos'[all((any(map(lambda c: eval(c.replace(' ', '!=')), d)) for d in zip(D, D[1:], D[2:])))::2])


N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
k = 0
for d in D:
	if d[0] == d[1]:
		k += 1
		if k >= 3:
			print('Yes')
			return
	else:
		k = 0
print('No')


N = int(input())
cnt = 0
for _ in range(N):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		cnt += 1
	else:
		cnt = 0
	if cnt >= 3:
		print('Yes')
		exit()
print('No')


from sys import stdin
N = int(stdin.readline().rstrip())
D = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
doublets = 0
for d in D:
	if d[0] == d[1]:
		doublets += 1
	else:
		doublets = 0
	if doublets >= 3:
		print('Yes')
		return
print('No')


n = int(input())
(d_1_1, d_1_2) = map(int, input().split())
(d_2_1, d_2_2) = map(int, input().split())
for _ in range(n - 2):
	(d_3_1, d_3_2) = map(int, input().split())
	if d_1_1 == d_1_2 and d_2_1 == d_2_2 and (d_3_1 == d_3_2):
		print('Yes')
		return
	(d_1_1, d_1_2) = (d_2_1, d_2_2)
	(d_2_1, d_2_2) = (d_3_1, d_3_2)
print('No')


N = int(input())
count = 0
for _ in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		count += 1
	else:
		count = 0
	if count == 3:
		print('Yes')
		return
print('No')


def main():
	n = int(input())
	cnt = 0
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		if a == b:
			cnt += 1
		else:
			cnt = 0
		if cnt > 2:
			print('Yes')
			return 0
	print('No')
main()


n = int(input())
a = []
b = []
for i in range(n):
	(x, y) = input().split(' ')
	a.append(x)
	b.append(y)
res = False
c = 0
for i in range(n):
	if a[i] == b[i]:
		if c == 2:
			res = True
			break
		c += 1
	else:
		c = 0
print('Yes' if res else 'No')


def main():
	n = int(input())
	cont = 0
	for _ in range(n):
		(a, b) = input().split()
		if a == b:
			cont += 1
			if cont >= 3:
				print('Yes')
				return
		else:
			cont = 0
	print('No')

def __starting_point():
	main()
__starting_point()


N = int(input())
zoro = 0
for n in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		zoro += 1
	else:
		zoro = 0
	if zoro == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
d = [input().split() for _ in range(n)]
if any((i[0] == i[1] and j[0] == j[1] and (k[0] == k[1]) for (i, j, k) in zip(d, d[1:], d[2:]))):
	print('Yes')
else:
	print('No')


print('NYoe s'['000' in ''.join((str(eval(t.replace(*' -'))) for t in open(0)))::2])


n = int(input())
a = 0
ok = False
for i in range(0, n):
	(x, y) = list(map(int, input().split()))
	if x == y:
		a = a + 1
		if a >= 3:
			ok = True
	else:
		a = 0
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
zoro = 0
flg = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		zoro += 1
	else:
		zoro = 0
	if zoro == 3:
		flg = 1
if flg == 1:
	print('Yes')
else:
	print('No')


n = int(input())
c = 0
d = False
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		c += 1
	else:
		c = 0
	d = d or c == 3
print('Yes' if d else 'No')


N = int(input())
D = [[0, 0] for i in range(N)]
for i in range(N):
	D[i] = list(map(int, input().split()))
ans = 'No'
for i in range(N - 2):
	if D[i][0] == D[i][1] and D[i + 1][0] == D[i + 1][1] and (D[i + 2][0] == D[i + 2][1]):
		ans = 'Yes'
print(ans)


N = int(input())
c = 0
ans = 'No'
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
	else:
		c = 0
	if c == 3:
		ans = 'Yes'
print(ans)


n = int(input())
c = 0
m = 1
for i in [0] * n:
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
		if c == 3:
			m = 0
	else:
		c = 0
print('YNeos'[m == 1::2])


N = int(input())
j = 0
J = 0
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		j += 1
		if j >= 3:
			J = 3
	else:
		j = 0
if J >= 3:
	print('Yes')
else:
	print('No')


N = int(input())
current_doublet_count = 0
for i in range(N):
	(d1, d2) = map(int, input().split(' '))
	if d1 == d2:
		current_doublet_count += 1
		if current_doublet_count >= 3:
			break
	else:
		current_doublet_count = 0
print('Yes' if current_doublet_count >= 3 else 'No')


N = int(input())
Ml = 0
l = 0
for i in range(N):
	(a, b) = input().split()
	if a == b:
		l += 1
		Ml = max(Ml, l)
	else:
		l = 0
print('Yes') if Ml >= 3 else print('No')


N = int(input())
l = [list(map(int, input().split())) for l in range(N)]
k = 0
for i in range(N):
	if l[i][0] == l[i][1]:
		k += 1
	if l[i][0] != l[i][1]:
		k = 0
	if k == 3:
		print('Yes')
		break
else:
	print('No')


N = int(input())
D = list()
D.append(0)
for i in range(1, N + 1):
	(x, y) = input().split()
	s = 1 + D[i - 1] if x == y else 0
	D.append(s)
if 3 in D:
	print('Yes')
else:
	print('No')


a = int(input())
l = []
(c, f) = (0, 0)
for i in range(a):
	(ta, tb) = map(int, input().split())
	if ta == tb:
		c += 1
	else:
		c = 0
	if c >= 3:
		f = 1
print('YNeos'[f == 0::2])


n = int(input())
arr = []
for _ in range(n):
	(d1, d2) = input().split()
	if d1 == d2:
		arr.append(True)
	else:
		arr.append(False)
for i in range(n - 2):
	if arr[i] and arr[i + 1] and arr[i + 2]:
		print('Yes')
		break
else:
	print('No')


n = int(input())
c = 0
z = 'No'
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		c += 1
	else:
		c = 0
	if c == 3:
		z = 'Yes'
		break
print(z)


n = int(input())
D = [[int(x) for x in input().split()] for _ in range(n)]
print('Yes' if any((a[0] == a[1] and b[0] == b[1] and (c[0] == c[1]) for (a, b, c) in zip(D, D[1:], D[2:]))) else 'No')


n = int(input())
d = [tuple(map(int, input().split())) for _ in [0] * n]
r = 'No'
c = 0
for (i, j) in d:
	if i == j:
		c += 1
	else:
		c = 0
	if c == 3:
		r = 'Yes'
		break
print(r)


N = int(input())
con = 0
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		con += 1
		if con == 3:
			print('Yes')
			exit()
	else:
		con = 0
print('No')


N = int(input())
zc = 0
ret = 'No'
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		zc += 1
		if zc == 3:
			ret = 'Yes'
	else:
		zc = 0
print(ret)


N = int(input())
cnt = 0
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		cnt += 1
	elif cnt == 3:
		break
	else:
		cnt = 0
if cnt >= 3:
	print('Yes')
else:
	print('No')


print('NYoe s'['111' in ''.join((str(len({*t.split()})) for t in open(0)))[1:]::2])


n = int(input())
count = 0
for _ in range(n):
	if count >= 3:
		break
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		count += 1
	else:
		count = 0
print('Yes' if count >= 3 else 'No')


n = int(input())
j = 0
r = 'No'
for i in range(n):
	(l, m) = map(int, input().split())
	if l == m:
		j += 1
	else:
		j = 0
	if j == 3:
		r = 'Yes'
		break
print(r)


n = int(input())
arr = []
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	arr.append([a, b])
ans = False
for i in range(1, n - 1):
	if arr[i][0] == arr[i][1] and arr[i - 1][0] == arr[i - 1][1] and (arr[i + 1][0] == arr[i + 1][1]):
		ans = True
		break
if ans:
	print('Yes')
else:
	print('No')


count = 0
n = int(input())
for i in range(n):
	dice = input().split()
	if dice[0] == dice[1]:
		count += 1
	else:
		count = 0
	if count == 3:
		break
if count == 3:
	print('Yes')
else:
	print('No')


N = int(input())
a = 0
for i in range(N):
	(Di1, Di2) = input().split()
	if Di1 == Di2:
		a = a + 1
		if a == 3:
			break
		else:
			a = a
	else:
		a = 0
if a >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
d = []
z = 0
for i in range(n):
	(d1, d2) = map(int, input().split())
	z = z + 1 if d1 == d2 else 0
	d.append(z)
ans = 'Yes' if max(d) >= 3 else 'No'
print(ans)


N = int(input())
D = [[int(x) for x in input().split(' ')] for _ in range(0, N)]
count = 0
flag = False
for (x, y) in D:
	if x == y:
		count += 1
	else:
		count = 0
	if count == 3:
		print('Yes')
		flag = True
		break
if not flag:
	print('No')


n = int(input())
d = ''
for _ in range(n):
	inp = input().split()
	if inp[0] == inp[1]:
		d += 'T'
	else:
		d += 'F'
if d.count('TTT') > 0:
	print('Yes')
else:
	print('No')


N = int(input())
ans = 'No'
n = 0
for _ in range(N):
	(x, y) = map(int, input().split())
	if x == y:
		n += 1
	else:
		n = 0
	if n >= 3:
		ans = 'Yes'
print(ans)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
for i in range(n):
	if a[i][0] == a[i][1]:
		x += 1
	else:
		x = 0
	if x == 3:
		print('Yes')
		y += 1
		break
if y == 0:
	print('No')


n = int(input())
cnt = 0
ans = 'No'
for _ in range(n):
	d = list(map(int, input().split()))
	if d[0] == d[1]:
		cnt += 1
	else:
		cnt = 0
	if cnt >= 3:
		ans = 'Yes'
print(ans)


n = int(input())
c = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
	if a != b:
		c = 0
	if c == 3:
		print('Yes')
		break
if c < 3:
	print('No')


c = 0
ans = 'No'
for _ in range(int(input())):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		c += 1
	else:
		c = 0
	if c == 3:
		ans = 'Yes'
print(ans)


t = int(input())
k = 0
for i in range(t):
	(n, m) = map(int, input().split())
	if n == m:
		k += 1
	else:
		k = 0
	if k == 3:
		break
if k == 3:
	print('Yes')
else:
	print('No')


N = int(input())
count = 0
result = 'No'
for _ in range(N):
	(x, y) = map(int, input().split())
	if x == y:
		count += 1
		if count == 3:
			result = 'Yes'
	else:
		count = 0
print(result)


n = int(input())
s = ''
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		s += 'a'
	else:
		s += 'b'
if 'aaa' in s:
	print('Yes')
else:
	print('No')


import sys
N = int(input())
cnt = 0
ans = 'No'
for i in range(N):
	(D_1, D_2) = map(int, input().split())
	if D_1 == D_2:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		ans = 'Yes'
print(ans)


n = int(input())
count = 0
flag = False
while n:
	(a, b) = input().split()
	if a == b:
		count += 1
	else:
		count = 0
	if count >= 3:
		flag = True
	n -= 1
if flag:
	print('Yes')
else:
	print('No')


N = int(input())
cnt = 0
for i in range(N):
	(a, b) = list(map(int, input().split()))
	if a == b:
		cnt += 1
		if cnt == 3:
			print('Yes')
			return
	else:
		cnt = 0
print('No')


n = int(input())
cnt = 0
ans = 'No'
for i in range(n):
	(d, k) = map(int, input().split())
	if d == k:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		ans = 'Yes'
		break
print(ans)


cnt = 0
M = int(input())
for i in range(M):
	(x, y) = map(int, input().split())
	if x == y:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		break
if cnt < 3:
	print('No')


n = int(input())
count = 0
for num in range(n):
	(s, t) = input().split()
	if s == t:
		count += 1
		if count == 3:
			print('Yes')
			exit()
	else:
		count = 0
print('No')


n = int(input())
same = [False] * n
for i in range(n):
	(d1, d2) = list(map(int, input().split()))
	if d1 == d2:
		same[i] = True
for i in range(n - 2):
	if same[i] and same[i + 1] and same[i + 2]:
		print('Yes')
		return
print('No')


def cin():
	return list(map(int, input().split()))
label = 'No'
times = int(input())
count = 0
for i in range(times):
	zorome = cin()
	if zorome[0] == zorome[1]:
		count += 1
	else:
		count = 0
	if count == 3:
		label = 'Yes'
print(label)


c = t = 0
for _ in range(int(input())):
	(x, y) = input().split()
	if x == y:
		c += 1
	else:
		c = 0
	t = max(t, c)
if t >= 3:
	print('Yes')
else:
	print('No')


N = int(input())
ans = 'No'
cnt = 0
for _ in range(N):
	(d1, d2) = input().split()
	if d1 == d2:
		cnt += 1
		if cnt == 3:
			break
	else:
		cnt = 0
if cnt == 3:
	ans = 'Yes'
print(ans)


d = 0
o = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		d += 1
	else:
		d = 0
	if d == 3:
		o = 1
if o:
	print('Yes')
else:
	print('No')


n = int(input())
f = False
match = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		match += 1
		f |= match == 3
	else:
		match = 0
if f:
	print('Yes')
else:
	print('No')


c = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
	else:
		c = 0
	if c > 2:
		break
else:
	print('No')
	quit()
print('Yes')


n = int(input())
count = 0
judge = False
for _ in range(n):
	(d1, d2) = [int(x) for x in input().split()]
	if d1 == d2:
		count += 1
		if count >= 3:
			judge = True
	else:
		count = 0
if judge:
	print('Yes')
else:
	print('No')


N = int(input())
c = 0
d = 0
for i in range(N):
	s = list(map(int, input().split()))
	if s[0] == s[1]:
		c = c + 1
		if c == 3:
			d = d + 1
	else:
		c = 0
if d > 0:
	print('Yes')
else:
	print('No')


N = int(input())
a = 0
for i in range(N):
	(D, F) = map(int, input().split())
	if D == F:
		a += 1
	else:
		a = 0
	if a == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
cnt = 0
for _ in range(n):
	d = input().split()
	if d[0] == d[1]:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
(x, y) = [list(i) for i in zip(*xy)]
three = []
for i in range(N):
	if x[i] == y[i]:
		three.append(1)
	else:
		three.append(0)
cnt = 0
max = 0
for i in range(N - 1):
	if three[i] == 1 and three[i + 1] == 1:
		cnt += 1
		if max < cnt:
			max = cnt
	else:
		cnt = 0
if max + 1 >= 3:
	print('Yes')
else:
	print('No')


N = int(input())
c = 0
for _ in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
	else:
		c = 0
	if c >= 3:
		print('Yes')
		exit()
print('No')


N = int(input())
a = 0
for i in range(N):
	(x, y) = map(int, input().split())
	if x == y:
		a += 1
	elif a < 3:
		a = 0
print('Yes' if a >= 3 else 'No')


N = int(input())
D1 = [''] * N
D2 = [''] * N
for i in range(N):
	[D1[i], D2[i]] = list(map(int, input().split()))
flag = False
for i in range(0, N - 2):
	if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and (D1[i + 2] == D2[i + 2]):
		print('Yes')
		flag = True
		break
if flag == False:
	print('No')


n = int(input())
count = 0
an = 0
for i in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		count += 1
	else:
		count = 0
	if count == 3:
		an = 1
if an == 1:
	print('Yes')
else:
	print('No')


a = 0
for _ in range(int(input())):
	(i, j) = map(int, input().split())
	if i == j:
		a += 1
		if a >= 3:
			print('Yes')
			exit()
	else:
		a = 0
print('No')


n = int(input())
count = 0
say = 'No'
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	if a == b:
		count += 1
		if count >= 3:
			say = 'Yes'
	else:
		count = 0
print(say)


import numpy as np
N = int(input())
dice = [input() for i in range(N)]
DICE = np.array([[int(i.split()[0]), int(i.split()[1])] for i in dice])
a1 = np.where(DICE[:-2, 0] == DICE[:-2, 1], 1, 0)
a2 = np.where(DICE[1:-1, 0] == DICE[1:-1, 1], 1, 0)
a3 = np.where(DICE[2:, 0] == DICE[2:, 1], 1, 0)
if sum(a1 * a2 * a3) > 0:
	print('Yes')
else:
	print('No')


n = int(input())
a = 0
b = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		b += 1
		a = max(a, b)
	else:
		b = 0
print('Yes') if a > 2 else print('No')


input = __import__('sys').stdin.readline
ans = 'No'
cs = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		cs += 1
	else:
		cs = 0
	if cs >= 3:
		ans = 'Yes'
print(ans)


n = int(input())
L = [input().split() for _ in range(n)]
i = 0
for item in L:
	if item[0] == item[1]:
		i = i + 1
		if i == 3:
			break
	else:
		i = 0
print('Yes' if i == 3 else 'No')


N = int(input())
ans = [False] * 3
for i in range(N):
	(D1, D2) = input().split()
	ans[i % 3] = D1 == D2
	if all(ans):
		break
print('Yes' if all(ans) else 'No')


n = int(input())
ans = 'No'
x = 0
for _ in range(n):
	(d1, d2) = input().split()
	if d1 == d2:
		x += 1
	else:
		x = 0
	if x == 3:
		ans = 'Yes'
print(ans)


N = int(input())
3 <= N <= 100
D1_D2 = [map(int, input().split()) for _ in range(N)]
(D1, D2) = [list(i) for i in zip(*D1_D2)]
right = int()
for s in range(0, N - 2):
	if D1[s] == D2[s] and D1[s + 1] == D2[s + 1] and (D1[s + 2] == D2[s + 2]):
		right += 1
if right >= 1:
	print('Yes')
else:
	print('No')


n = int(input())
p = 0
k = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		p += 1
	else:
		p = 0
	if p >= 3:
		k = 1
print('Yes') if k else print('No')


n = input()
count = 0
for i in range(int(n)):
	roll = input()
	if roll[0] == roll[2]:
		count = count + 1
		if count == 3:
			break
	else:
		count = 0
if count >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
cnt = 0
for i in range(n):
	(l, r) = map(int, input().split())
	if l == r:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
ct = 0
best = 0
arr = []
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		ct += 1
		best = max(ct, best)
	else:
		ct = 0
if best >= 3:
	print('Yes')
else:
	print('No')


yes_count = 0
for count in range(int(input())):
	(a, b) = input().split()
	if a == b:
		yes_count += 1
	elif yes_count < 3:
		yes_count = 0
if yes_count >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
ans = chk = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		chk += 1
	else:
		chk = 0
	ans = max(ans, chk)
print('Yes' if ans > 2 else 'No')


N = int(input())
count = 0
flag = 'No'
for x in range(N):
	a = input().split()
	if a[0] == a[1]:
		count += 1
		if count == 3:
			flag = 'Yes'
	else:
		count = 0
print(flag)


N = int(input())
flag = 'No'
cnt = 0
for i in range(N):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		cnt += 1
		if cnt == 3:
			flag = 'Yes'
	else:
		cnt = 0
print(flag)


N = int(input())
num = 0
for i in range(N):
	(x, y) = map(int, input().split())
	if x == y:
		num += 1
	else:
		num = 0
	if num == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
D_list = []
for i in range(N):
	s = list(map(int, input().split()))
	D_list.append(s)
a2 = D_list[0][0]
b2 = D_list[0][1]
a1 = D_list[1][0]
b1 = D_list[1][1]
for i in range(2, N):
	a0 = D_list[i][0]
	b0 = D_list[i][1]
	if a2 == b2 and a1 == b1 and (a0 == b0):
		print('Yes')
		return
	a2 = a1
	b2 = b1
	a1 = a0
	b1 = b0
print('No')


print('YNeos'['000' not in ''.join([str(eval(input().replace(' ', '-'))) for _ in '_' * int(input())])::2])


import sys
N = int(input())
x = 0
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		x += 1
	else:
		x = 0
	if x == 3:
		print('Yes')
		sys.exit()
print('No')


N = int(input())
c = 0
for i in range(N):
	D = list(map(int, input().split()))
	if D[0] == D[1]:
		c += 1
	else:
		c = 0
	if c == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
ln = 0
mx = 0
for _ in range(n):
	(l, r) = map(int, input().split())
	if l == r:
		ln += 1
	else:
		ln = 0
	mx = max(mx, ln)
if mx >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
max_cnt = 0
now_cnt = 0
for i in range(n):
	if len(set(l[i])) == 1:
		now_cnt += 1
		max_cnt = max(max_cnt, now_cnt)
	else:
		now_cnt = 0
print('Yes' if max_cnt >= 3 else 'No')


n = int(input())
dList = []
count = 0
s = 'No'
for i in range(n):
	d = []
	(d1, d2) = list(map(int, input().split()))
	d.append(d1)
	d.append(d2)
	dList.append(d)
for i in range(n - 2):
	if dList[i][0] == dList[i][1] and dList[i + 1][0] == dList[i + 1][1] and (dList[i + 2][0] == dList[i + 2][1]):
		s = 'Yes'
		break
print(s)


n = int(input())
m = 0
l = 0
for i in range(n):
	(A, B) = map(int, input().split())
	if A == B:
		m += 1
	else:
		m = 0
	if m == 3:
		print('Yes')
		l = 1
		break
if l == 0:
	print('No')


n = int(input())
o = 'No'
j = 0
for i in range(n):
	(a, b) = list(map(int, input('').split()))
	if a == b:
		j += 1
		if j == 3:
			o = 'Yes'
	else:
		j = 0
print(o)


n = int(input())
d = []
for i in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		d.append(i)
result = 'No'
if len(d) <= 2:
	print(result)
else:
	for h in range(len(d) - 2):
		if d[h] == d[h + 1] - 1 == d[h + 2] - 2:
			result = 'Yes'
			break
	print(result)


a = int(input())
xy = [map(int, input().split()) for _ in range(a)]
(x, y) = [list(i) for i in zip(*xy)]
f = 0
for i in range(len(x)):
	if x[i] == y[i] and len(x) > i + 2:
		for j in range(1, 3):
			if x[i + j] != y[i + j]:
				break
		else:
			print('Yes')
			break
else:
	print('No')


c = int(input())
ans = 0
now = 0
for _ in range(c):
	if eval(input().replace(' ', '==')):
		now = now + 1
	else:
		now = 0
	ans = max(ans, now)
print('Yes') if ans >= 3 else print('No')


N = input()
Dies = []
for x in range(int(N)):
	Dies.append(input().split())
counter = 0
z = 0
for y in Dies:
	if y[0] == y[1]:
		counter = counter + 1
	else:
		counter = 0
	if counter == 3:
		z = 1
		break
if z == 0:
	print('No')
else:
	print('Yes')


n = int(input())
cnt = 0
flg = False
for _ in range(n):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		cnt += 1
	else:
		cnt = 0
	if cnt >= 3:
		flg = True
print('Yes' if flg else 'No')


N = int(input())
d = [0] * N
D = [0] * N
s = 0
for i in range(N):
	(d[i], D[i]) = map(int, input().split())
	if d[i] == D[i]:
		s += 1
	else:
		s = 0
	if s == 3:
		print('Yes')
		exit()
print('No')


n = int(input())
c = 0
o = ''
for _ in range(n):
	(d, d1) = map(int, input().split())
	if d == d1:
		c += 1
		if c == 3:
			o = 'Yes'
	else:
		c = 0
if o == '':
	o = 'No'
print(o)


n = int(input())
k = 0
flag = False
while n:
	(a, b) = map(int, input().split())
	if a == b:
		k += 1
	else:
		k = 0
	if k == 3:
		flag = True
		break
	n -= 1
print('Yes' if flag else 'No')


n = int(input())
zorome = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		zorome += 1
	else:
		zorome = 0
	if zorome == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
sig = 0
Ans = 'No'
for i in range(N):
	(C, D) = map(int, input().split())
	if C == D:
		sig += 1
	else:
		sig = 0
	if sig == 3:
		Ans = 'Yes'
print(Ans)


N = int(input())
f = 0
ans = 'No'
for i in range(N):
	(d1, d2) = map(int, input().split())
	if d1 == d2:
		f += 1
		if f == 3:
			ans = 'Yes'
	else:
		f = 0
print(ans)


N = input()
n = int(N)
x = 0
for s in range(n):
	(ds1, ds2) = input().split()
	if ds1 == ds2:
		x += 1
	else:
		x = 0
	if x == 3:
		print('Yes')
		break
else:
	print('No')


n = int(input())
d = [list(map(int, input().split())) for l in range(n)]
for i in range(n - 2):
	if d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and (d[i + 2][0] == d[i + 2][1]):
		print('Yes')
		return
print('No')


N = int(input())
cnt = 0
mx = 0
for _ in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		cnt += 1
		mx = max(cnt, mx)
	else:
		cnt = 0
print('Yes' if mx > 2 else 'No')


n = int(input())
ch = 0
l = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		l += 1
	else:
		l = 0
	if l >= 3:
		ch += 1
if ch > 0:
	print('Yes')
else:
	print('No')


n = int(input())
m = 0
c = 0
for _ in range(n):
	(n1, n2) = map(int, input().split())
	if n1 == n2:
		c += 1
		m = max(m, c)
	else:
		m = max(m, c)
		c = 0
if m >= 3:
	print('Yes')
else:
	print('No')


n = int(input())
ans = 'No'
j = 0
for i in range(n):
	(d, dd) = map(str, input().split())
	if d == dd:
		j += 1
	else:
		j = 0
	if j >= 3:
		ans = 'Yes'
print(ans)


n = int(input())
m = 0
c = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a == b:
		c += 1
	else:
		c = 0
	m = max(m, c)
if m < 3:
	print('No')
else:
	print('Yes')


N = int(input())
dices = [list(map(int, input().split())) for _ in range(N)]
dices = ''.join(list([str(int(x[0] == x[1])) for x in dices]))
print('Yes' if '111' in dices else 'No')


N = int(input())
index = 0
for n in range(N):
	Input = input().split()
	if Input[0] == Input[1]:
		index += 1
	else:
		index = 0
	if index == 3:
		break
if index == 3:
	print('Yes')
else:
	print('No')


a = []
n = int(input())
for i in range(n):
	a.append(input().split())
f = False
i = 0
while i < n - 2 and f == False:
	if a[i][0] == a[i][1] and a[i + 1][0] == a[i + 1][1] and (a[i + 2][0] == a[i + 2][1]):
		f = True
	i = i + 1
if f == False:
	print('No')
else:
	print('Yes')


N = int(input())
D = []
for i in range(N):
	(D1, D2) = input().split()
	D.append([D1, D2])
for i in range(N - 2):
	for j in range(3):
		if D[j + i][0] != D[j + i][1]:
			break
	else:
		print('Yes')
		return
print('No')


N = int(input())
D1 = []
D2 = []
for i in range(N):
	(a, b) = list(map(int, input().split()))
	D1.append(a)
	D2.append(b)
counter = 0
flg = False
for i in range(N):
	if D1[i] == D2[i]:
		counter = counter + 1
		if counter == 3:
			flg = True
	else:
		counter = 0
if flg:
	print('Yes')
else:
	print('No')


n = int(input())
li = ''
for _ in range(n):
	(a, b) = (int(x) for x in input().split())
	if a == b:
		li += 't'
	else:
		li += 's'
print('Yes' if 'ttt' in li else 'No')


(_, *d) = [{*t.split()} for t in open(0)]
print('YNeos'[all((max(map(len, d[i:i + 3])) > 1 for i in range(len(d) - 2)))::2])


N = int(input())
rep = 0
result = 'No'
for i in range(N):
	(a, b) = map(int, input().split())
	if a == b:
		rep += 1
	else:
		rep = 0
	if rep == 3:
		result = 'Yes'
		break
print(result)


a = []
n = int(input())
for i in range(0, n):
	a.append(input().split())
	a[i][0] = int(a[i][0])
	a[i][1] = int(a[i][1])
cnt = 0
flg = False
j = 0
while j < n and flg == False:
	if a[j][1] == a[j][0]:
		cnt = cnt + 1
	else:
		cnt = 0
	if cnt == 3:
		flg = True
	j = j + 1
if flg == True:
	print('Yes')
else:
	print('No')


n = int(input())
t = 0
for _ in range(n):
	(d1, d2) = map(int, input().split())
	if d1 != d2:
		t = 0
	else:
		t += 1
	if t == 3:
		print('Yes')
		exit()
print('No')


N = int(input())
C = 0
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		C += 1
	else:
		C = 0
	if C > 2:
		print('Yes')
		break
else:
	print('No')


N = int(input())
(count, result) = (0, 0)
for i in range(N):
	(D1, D2) = map(int, input().split())
	if D1 == D2:
		count += 1
	else:
		count = 0
	if count == 3:
		result = 1
print('Yes' if result == 1 else 'No')


n = int(input())
ans = 'No'
count = 0
for i in range(n):
	(D1, D2) = map(int, input().split())
	count = count + 1 if D1 == D2 else 0
	ans = 'Yes' if count >= 3 else ans
print(ans)


N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
	if all((D[j][0] == D[j][1] for j in range(i, i + 3))):
		print('Yes')
		break
else:
	print('No')


def judge():
	cnt = 0
	for _ in range(N):
		(x, y) = map(int, input().split())
		if x == y:
			cnt += 1
		else:
			cnt = 0
		if cnt == 3:
			return True
	return False
N = int(input())
if judge():
	print('Yes')
else:
	print('No')


number = int(input())
doublets = 0
for i in range(number):
	(dice1, dice2) = list(map(int, input().split()))
	if dice1 == dice2:
		doublets += 1
	else:
		doublets = 0
	if doublets == 3:
		break
if doublets == 3:
	print('Yes')
else:
	print('No')


n = int(input())
count = 0
for i in range(n):
	(d1, d2) = list(map(int, input().split()))
	if d1 == d2:
		count += 1
	elif count == 3:
		break
	else:
		count = 0
if count >= 3:
	print('Yes')
else:
	print('No')


import math
from collections import deque
from typing import Deque, Dict, List, Optional, Tuple, Union

def main(N: int, D: List[List[int]]):
	consecutive = 0
	for (a, b) in D:
		if a == b:
			consecutive += 1
			if consecutive >= 3:
				print('Yes')
				return
		else:
			consecutive = 0
	print('No')

def __starting_point():
	N = int(input())
	D: List[List[int]] = []
	for _ in range(N):
		(a, b) = list(map(int, input().split()))
		D.append([a, b])
	main(N, D)
__starting_point()


N = int(input())
zoro = 0
res = 0
for _ in [0] * N:
	(a, b) = map(int, input().split())
	if a == b:
		zoro += 1
		res = max(res, zoro)
	else:
		zoro = 0
print(['No', 'Yes'][res > 2])


N = int(input())
flag = 0
ans = 'No'
for i in range(N):
	(A, B) = input().split()
	if A == B:
		flag += 1
	else:
		flag = 0
	if flag == 3:
		ans = 'Yes'
		break
print(ans)


n = int(input())
c = 0
yea = False
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a == b:
		c += 1
		if c == 3:
			yea = True
	else:
		c = 0
print('Yes' if yea else 'No')


n = int(input())
p = 0
f = 0
for i in range(n):
	d = input().split()
	if d[0] == d[1]:
		p += 1
	else:
		p = 0
	if p == 3:
		f = 1
if f == 1:
	print('Yes')
else:
	print('No')