//package atcoder.beginner179;

import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
}

 import java.io.*; io.* java import java.util.*; util.* java public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
} Main static InputReader in; in static PrintWriter out; out public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    } main {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    } initReaderPrinter(false) initReaderPrinter false solve(1) solve 1 String[] args args static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    } solve {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    } for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        } int testNumber = 0; int testNumber = 0; testNumber 0 testNumber < testCnt testNumber testCnt testNumber++ testNumber++ testNumber {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        } {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] d1 = new int[n] d1 new int[n] n d2 = new int[n]; d2 new int[n] n for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            } {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            } d1[i] = in.nextInt() d1[i] d1 i in.nextInt() in.nextInt in d2[i] = in.nextInt() d2[i] d2 i in.nextInt() in.nextInt in int cnt = 0; cnt 0 boolean found = false; found false for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            } {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            } if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                } d1[i] == d2[i] d1[i] d1 i d2[i] d2 i {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                } cnt++ cnt if(cnt == 3) {
                        found = true;
                        break;
                    } cnt == 3 cnt 3 {
                        found = true;
                        break;
                    } found = true found true break; {
                    cnt = 0;
                } cnt = 0 cnt 0 out.print(found ? "Yes" : "No") out.print out found ? "Yes" : "No" found "Yes" "No" out.close() out.close out int testCnt testCnt static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    } initReaderPrinter {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    } if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        } test {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } in = new InputReader(new FileInputStream("src/input.in")) in new InputReader(new FileInputStream("src/input.in")) out = new PrintWriter(new FileOutputStream("src/output.out")) out new PrintWriter(new FileOutputStream("src/output.out")) {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        } in = new InputReader(System.in) in new InputReader(System.in) out = new PrintWriter(System.out) out new PrintWriter(System.out) boolean test test static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    } InputReader BufferedReader br; br StringTokenizer st; st InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } InputReader {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            } Exception e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } br = new BufferedReader(new InputStreamReader(stream), 32768) br new BufferedReader(new InputStreamReader(stream), 32768) InputStream stream stream String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        } nextIntArray {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        } Integer[] a = new Integer[n]; a new Integer[n] n for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                a[i] = nextInt();
            } {
                a[i] = nextInt();
            } a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        } nextLongArray {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        } Long[] a = new Long[n]; a new Long[n] n for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                a[i] = nextLong();
            } {
                a[i] = nextLong();
            } a[i] = nextLong() a[i] a i nextLong() nextLong return a; a int n n public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
} public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
} Main
//package atcoder.beginner179;

import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        //initReaderPrinter(true);
        initReaderPrinter(false);
        //solve(in.nextInt());
        solve(1);        
    }

    static void solve(int testCnt) {
        for (int testNumber = 0; testNumber < testCnt; testNumber++) {
            int n = in.nextInt();
            int[] d1 = new int[n], d2 = new int[n];
            for(int i = 0; i < n; i++) {
                d1[i] = in.nextInt();
                d2[i] = in.nextInt();
            }
            int cnt = 0;
            boolean found = false;
            for(int i = 0; i < n; i++) {
                if(d1[i] == d2[i]) {
                    cnt++;
                    if(cnt == 3) {
                        found = true;
                        break;
                    }
                }
                else {
                    cnt = 0;
                }
            }
            out.print(found ? "Yes" : "No");
        }   
        out.close();
    }

    static void initReaderPrinter(boolean test) {
        if (test) {
            try {
                in = new InputReader(new FileInputStream("src/input.in"));
                out = new PrintWriter(new FileOutputStream("src/output.out"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            in = new InputReader(System.in);
            out = new PrintWriter(System.out);
        }
    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        InputReader(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream), 32768);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        Integer[] nextIntArray(int n) {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        Long[] nextLongArray(int n) {
            Long[] a = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
}


