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: introductory

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 = [[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())
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)

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())
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())
count = 0
for i in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    count = count+1 
    if count >= 3:
      print("Yes")
      break
  else:
    count = 0
if(count != 3):
  print("No")

N = int(input())
3 <= N <= 100

D1_D2 = [map(int, input().split()) for _ in range(N)]
#print(D1_D2)
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())
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')

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


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

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


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

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

def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます

    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0

        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True

    # ダメでした
    return False

N = int(input())

if judge():
    # judge() で Trueが返ってくるとこっちに進みます
    print("Yes")
else:
    # Falseだとこっちです
    print("No")

n = int(input())
cnt = 0
for i in range(n):
  d1, d2 = list(map(int, input().split()))
  if d1 == d2:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    break
if cnt >= 3:
  print('Yes')
else:
  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 = 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());a=0;
for i in range(0,n):
    x ,y=map(int,input().split())
    if x==y:
        a+=1
        if a>=3:
            print('Yes')
            return
    else:
        a=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')


import math  # noqa: F401
from collections import deque  # noqa: F401
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401


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

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

#coding :utf-8

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)

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

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

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())
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())
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())
YN_list = []

a=0
for i in range(N):
  Di1,Di2 = input().split()
  if Di1 == Di2:
    a = a + 1
    if a >= 3:
      YN_list.append("Yes")
    else:
      YN_list.append("No")
  else:
    a = 0
    if a >= 3:
      YN_list.append("Yes")
    else:
      YN_list.append("No")

if 'Yes' in YN_list:
  print("Yes")
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())
D = [list(map(int, input().split())) for _ 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())

ctn_check = 0
for _ in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        ctn_check += 1
    else:
        ctn_check = 0
    if ctn_check == 3:
        break

if ctn_check == 3:
    print("Yes")
else:
    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")      

# -*- coding: utf-8 -*-

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

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

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())
jail = False
doubles = 0
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')

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

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

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,*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())
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())
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")
        break
else:
    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)

# -*- coding: utf-8 -*-
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)


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


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


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


# coding:utf-8

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

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

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)


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())
i=0
for s in range(n):
    a,b=list(map(int,input().split()))
    
    if (a==b):
        i+=1
    else:
        i=0
    if(i==3):
        break
if(i>=3):
    print("Yes")
else:
    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())

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

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


yes_count = 0
for count in range(int(input())):
    a,b = input().split()
    if a == b:
        yes_count += 1
    else:
        if yes_count < 3:
            yes_count = 0
if yes_count >= 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())
li=[]
k=0
for i in range(N):
    a,b=list(map(int,input().split()))
    if a==b:
        k+=1
    else:
        k*=0
    if k==3:
        print("Yes")
        return
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())
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 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")


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 = 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())
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())
cnt = 0
for _ in range(N):
    a,b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt == 3:
            print('Yes')
            return
    else:
        cnt = 0
print('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()

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

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

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


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,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")

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

N = int(input())

cnt = 0
ans = 'No'

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


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

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())
tmp = 0

for i in range(N):
  d1,d2 = map(int, input().split())
  if d1 == d2:
    tmp = tmp + 1
  else:
    tmp = 0
  if tmp == 3:
    break

if tmp == 3:
  print('Yes')
else:
  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')

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

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


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

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())
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())
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")



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


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

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