Problem:
Score : 200 points

Problem Statement

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 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

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

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

6
1 1
2 2
3 3
4 4
5 5
6 6

Sample Output 3

Yes

Solution in C++ (Clang 10.0.0) (judge verdict: Accepted)

#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <utility>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#define NDEBUG
#include <cassert>
#include <bitset>
using namespace std;

#define prv(a)            \
    for (auto x : a)      \
    {                     \
        cout << x << " "; \
    }                     \
    cout << '\n';
#define prvp(a)                                     \
    for (auto x : a)                                \
    {                                               \
        cout << x.first << " " << x.second << '\n'; \
    }                                               \
    cout << '\n';
#define F first
#define S second
#define bg begin()
#define ed end()
#define ll long long
#define ld long double
#define INF pow(10, 16)
#define all(v) v.begin(), v.end()
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define ub(a, x) upper_bound(all(a), x)
#define lb(a, x) lower_bound(all(a), x)
#define fill(a) memset(a, 0, sizeof(a))
#define fill1(a) memset(a, -1, sizeof(a))
#define f(a, b) for (ll i = a; i < b; i++)
#define fj(a, b) for (ll j = a; j < b; j++)
#define fk(a, b) for (ll k = a; k < b; k++)
#define fb(b, a) for (ll i = b; i > a; i--)
#define tr(it, v) for (auto it = v.bg; it != v.ed; it++)
#define dout(x) cout << x << '\n';
#define dout2(x, y) cout << x << " " << y << '\n';
#define dout3(x, y, z) cout << x << " " << y << " " << z << '\n';
#define pr1(x) cout << (x) << " ";
#define pr(x) cout << #x << " " << (x) << endl;
#define pr2(x, y) cout << #x << " " << (x) << "  " << #y << " " << (y) << endl;
#define pr3(x, y, z) cout << #x << " " << (x) << "  " << #y << " " << (y) << "  " << #z << " " << (z) << endl;
#define pp(x) cout << x.first << " " << x.second << endl;
ll min(ll a, ll b) { if(a < b) return a; else return b; } 
ll max(ll a, ll b) { if(a < b) return b; else return a; } 
ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); } 
ll max3(ll a, ll b, ll c) { return max(a, max(b , c)); } 
ll ceil1(ll x, ll y) { if(x % y) return (x + y) / y; else return x / y; }

ll NC = 100; 
ll N = 1e9 + 7;
const ll S = 1e5 + 7;

ll mod(ll n);
ll gcd(ll a, ll b); 
ll modM(ll n, ll m);
ll modA(ll n, ll m);
ll modS(ll n, ll m);
ll power(ll a, ll b);
void ipgraph(ll n, ll m);
//==============================================================================================

vector<vector<ll>> v;
vector<bool> vis;

void solve()
{ 
    ll n;
    cin >> n;
    ll cnt = 0, f = 0;
    while(n--)
    {
        ll x, y;
        cin >> x >> y; 
        if(x == y) cnt++;
        else cnt = 0;
        if(cnt == 3) f = 1;
    }
    cout << (f ? "Yes" : "No") << '\n'; 
}   

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("/Users/aturgupta/Desktop/CP/input.txt", "r", stdin);
    freopen("/Users/aturgupta/Desktop/CP/output.txt", "w", stdout);
#endif

    ll t;
    //cin >> t;
    t = 1; 
    while (t--) solve();
    cerr << endl << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

void ipgraph(ll n, ll m)
{
    v.assign(n, {});
    vis.assign(n, 0);
    ll x, y;
    f(0, m)
    {
        cin >> x >> y;
        x--, y--;
        v[y].push_back(x);
        v[x].push_back(y); 
    }
}

ll gcd(ll a, ll b)
{
    if (b > a) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll power(ll a, ll b)
{
    if (b == 0) return 1;
    ll c = power(a, b / 2);
    if (b % 2 == 0) return modM(c, c);
    else return modM(modM(c, c), a);
}

ll mod(ll n) {return (n % N + N) % N; }
ll modM(ll n, ll m) { return ((n % N * m % N) + N) % N; }
ll modA(ll n, ll m) { return ((n % N + m % N) + N) % N; }
ll modS(ll n, ll m) { return ((n % N - m % N) + N) % N; }