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++ (GCC 9.2.1) (judge verdict: Accepted)

/***********************************************
 *                                             *
 *   author: raghav_0901 (Raghav Dalmia)       *
 *   updated on: 19-09-2020,  5:36:09 pm IST   *
 *                                             *
\***********************************************/

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define int long long int
const int mod = (1e9) + 7;

// #define cerr  \
//     if (false) \
//     cerr
#define error(args...)                             \
    {                                              \
        string _s = #args;                         \
        replace(_s.begin( ), _s.end( ), ',', ' '); \
        stringstream _ss(_s);                      \
        istream_iterator<string> _it(_ss);         \
        err(_it, args);                            \
    }
void err(istream_iterator<string> it)
{
    cerr << '\n';
    cerr.flush( );
}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

void print( )
{
    cout << '\n';
    cout.flush( );
}
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << ' ';
    print(args...);
}

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;

#define endl '\n'

#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end); i += 1 - 2 * ((begin) > (end)))
#define ff(i, begin, end, fl) \
    for (__typeof(end) i = (begin); i != (end) && fl; i += 1 - 2 * ((begin) > (end)))

#define mem(arr, val) memset(arr, val, sizeof(arr));
#define ps(x, y) fixed << setprecision(y) << x
#define inf INT_MAX

#define fi first
#define se second
#define mpr(a, b) make_pair(a, b)
typedef pair<int, int> pr;

#define pb emplace_back
#define _in(v)                      \
    {                               \
        for (auto &x : v) cin >> x; \
    }
#define _out(v)                            \
    {                                      \
        for (auto x : v) cout << x << ' '; \
        cout << '\n';                      \
    }
typedef vector<int> vec;
#define all(x) (x).begin( ), (x).end( )
#define allr(x) (x).rbegin( ), (x).rend( )
#define each(i, v) for (auto &i : v)
#define sumv(v) accumulate(v.begin( ), v.end( ), 0)

template <typename T>
T max(vector<T> &v)
{
    return *max_element(all(v));
}

template <typename T>
T min(vector<T> &v)
{
    return *min_element(all(v));
}

#define setbits(x) __builtin_popcountll(x)
#define numbits(x) (64 - __builtin_clzll(x))
#define zerobit(x) __builtin_ctzll(x)
#define log2(x) (63 - __builtin_clzll(x))

#define pi 3.1415926535897932384626433

inline bool isPow2(int x) { return x && (!(x & (x - 1))); }
inline int n_sum(int n) { return (n * (n + 1)) >> 1; }

int pow(int a, int b)
{
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

inline int modinv(int k) { return pow(k, mod - 2); }
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }

inline int modinv(int k, int m) { return pow(k, m - 2); }
inline int add(int a, int b, int m) { return ((a % m) + (b % m)) % m; }
inline int sub(int a, int b, int m) { return ((a % m) - (b % m) + m) % m; }
inline int mul(int a, int b, int m) { return ((a % m) * (b % m)) % m; }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

double sum( ) { return 0.0; }
template <typename T, typename... Args>
T sum(T a, Args... args)
{
    return a + sum(args...);
}

void _main(void);
signed main( )
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    _main( );

    return 0;
}

//--------------------------- Main Function -----------------------

void _main(void)
{
    // code here

    int n, cnt = 0;
    bool fl = 0;
    cin >> n;
    f(i, 0, n)
    {
        int u, v;
        cin >> u >> v;
        if (!fl)
        {
            if (u == v)
            {
                cnt++;
                if (cnt >= 3)
                    fl = 1;
            }
            else
                cnt = 0;
        }
    }
    print((fl ? "Yes" : "No"));
    return;
}