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

public class Main {
	static InputReader scn = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	}

	public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	}

	public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	}

	public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	}

	public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	}

	public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	}

	public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}

	public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	}

	public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}

} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	static InputReader scn = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	}

	public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	}

	public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	}

	public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	}

	public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	}

	public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	}

	public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}

	public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	}

	public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}

} Main static InputReader scn = new InputReader(System.in); scn new InputReader(System.in) static OutputWriter out = new OutputWriter(System.out); out new OutputWriter(System.out) static final Random random = new Random(); random new Random() public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	} main {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	} int t = 1; t 1 while (t-- > 0)
			solve(); t-- > 0 t-- t 0 solve() solve out.close() out.close out String[] args args public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	} solve {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	} int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn int max = 0; max 0 int val = 0; val 0 while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		} n-- > 0 n-- n 0 {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		} int a = scn.nextInt(); a scn.nextInt() scn.nextInt scn int b = scn.nextInt(); b scn.nextInt() scn.nextInt scn if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			} a == b a b {
				val++;
				max = Math.max(max, val);
			} val++ val max = Math.max(max, val) max Math.max(max, val) Math.max Math max val {
				val = 0;
			} val = 0 val 0 if (max >= 3)
			out.println("Yes");
		else
			out.println("No"); max >= 3 max 3 out.println("Yes") out.println out "Yes" out.println("No") out.println out "No" public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	} CountFrequencies {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	} HashMap<Integer, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		} int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		} {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		} int a = arr[i]; a arr[i] arr i if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			} map.containsKey(a) map.containsKey map a {
				map.put(a, map.get(a) + 1);
			} map.put(a, map.get(a) + 1) map.put map a map.get(a) + 1 map.get(a) map.get map a 1 {
				map.put(a, 1);
			} map.put(a, 1) map.put map a 1 return map; map int[] arr arr public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	} countPrimeFactors {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	} int count = 0; count 0 while (n % 2 == 0) {
			n = n / 2;
			count++;
		} n % 2 == 0 n % 2 n 2 0 {
			n = n / 2;
			count++;
		} n = n / 2 n n / 2 n 2 count++ count for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		} int i = 3; int i = 3; i 3 i <= Math.sqrt(n) i Math.sqrt(n) Math.sqrt Math n i = i + 2 i = i + 2 i i + 2 i 2 {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		} {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		} while (n % i == 0) {
				n = n / i;
				count++;
			} n % i == 0 n % i n i 0 {
				n = n / i;
				count++;
			} n = n / i n n / i n i count++ count if (n > 2)
			count++; n > 2 n 2 count++ count return (count); (count) int n n public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	} max {
		if (a >= b)
			return a;
		return b;
	} if (a >= b)
			return a; a >= b a b return a; a return b; b int a a int b b public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	} min {
		if (a <= b)
			return a;
		return b;
	} if (a <= b)
			return a; a <= b a b return a; a return b; b int a a int b b public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	} gcd {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	} if (a == 0)
			return b; a == 0 a 0 return b; b return gcd(b % a, a); gcd(b % a, a) gcd b % a b a a long a a long b b public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	} lcm {
		return (a * b) / gcd(a, b);
	} return (a * b) / gcd(a, b); (a * b) / gcd(a, b) (a * b) a b gcd(a, b) gcd a b long a a long b b public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	} isPrime {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	} if (n < 2)
			return false; n < 2 n 2 return false; false if (n == 2 || n == 3)
			return true; n == 2 || n == 3 n == 2 n 2 n == 3 n 3 return true; true if (n % 2 == 0 || n % 3 == 0)
			return false; n % 2 == 0 || n % 3 == 0 n % 2 == 0 n % 2 n 2 0 n % 3 == 0 n % 3 n 3 0 return false; false long sqrtN = (long) Math.sqrt(n) + 1; sqrtN (long) Math.sqrt(n) + 1 (long) Math.sqrt(n) Math.sqrt Math n 1 for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		} long i = 6L; long i = 6L; i 6L i <= sqrtN i sqrtN i += 6 i += 6 i 6 {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		} {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		} if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false; n % (i - 1) == 0 || n % (i) + 1 == 0 n % (i - 1) == 0 n % (i - 1) n (i - 1) i 1 0 n % (i) + 1 == 0 n % (i) + 1 n % (i) n (i) 1 0 return false; false return true; true long n n public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	} SieveOfEratosthenes {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	} int n = arr.length; n arr.length arr arr.length for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		} long i = 3; long i = 3; i 3 i < n i n i = i + 2 i = i + 2 i i + 2 i 2 {
			arr[(int) i] = 1;
		} {
			arr[(int) i] = 1;
		} arr[(int) i] = 1 arr[(int) i] arr (int) i 1 for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		} long i = 3; long i = 3; i 3 i < n i n i = i + 2 i = i + 2 i i + 2 i 2 {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		} {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		} if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			} arr[(int) i] == 1 arr[(int) i] arr (int) i 1 {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			} for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				} long j = (long) i * i; long j = (long) i * i; j (long) i * i (long) i i j < n j n j = j + i j = j + i j j + i j i {
					arr[(int) j] = 0;
				} {
					arr[(int) j] = 0;
				} arr[(int) j] = 0 arr[(int) j] arr (int) j 0 arr[2] = 1 arr[2] arr 2 1 arr[0] = arr[1] = 0 arr[0] arr 0 arr[1] = 0 arr[1] arr 1 0 return arr; arr int[] arr arr static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	} sort {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	} ArrayList<Integer> l = new ArrayList<>(); l new ArrayList<>() for (int i : a) {
			l.add(i);
		} int i a {
			l.add(i);
		} {
			l.add(i);
		} l.add(i) l.add l i Collections.sort(l) Collections.sort Collections l for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i {
			a[i] = l.get(i);
		} {
			a[i] = l.get(i);
		} a[i] = l.get(i) a[i] a i l.get(i) l.get l i int[] a a public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	} printPermutn {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	} if (str.length() == 0) {
			list.add(ans);
		} str.length() == 0 str.length() str.length str 0 {
			list.add(ans);
		} list.add(ans) list.add list ans for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		} int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		} {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		} char ch = str.charAt(i); ch str.charAt(i) str.charAt str i String ros = str.substring(0, i) + str.substring(i + 1); ros str.substring(0, i) + str.substring(i + 1) str.substring(0, i) str.substring str 0 i str.substring(i + 1) str.substring str i + 1 i 1 printPermutn(ros, ans + ch, list) printPermutn ros ans + ch ans ch list return list; list String str str String ans ans ArrayList<String> list list public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	} binarySearch {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	} if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		} r >= l r l {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		} int mid = l + (r - l) / 2; mid l + (r - l) / 2 l (r - l) / 2 (r - l) r l 2 if (arr[mid] == x)
				return mid; arr[mid] == x arr[mid] arr mid x return mid; mid if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x); arr[mid] > x arr[mid] arr mid x return binarySearch(arr, l, mid - 1, x); binarySearch(arr, l, mid - 1, x) binarySearch arr l mid - 1 mid 1 x return binarySearch(arr, mid + 1, r, x); binarySearch(arr, mid + 1, r, x) binarySearch arr mid + 1 mid 1 r x return -1; -1 1 int arr[] arr int l l int r r int x x public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	} firstOccurence {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	} if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		} low <= high low high {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		} int mid = low + (high - low) / 2; mid low + (high - low) / 2 low (high - low) / 2 (high - low) high low 2 if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n); (mid == 0 || x > array1[mid - 1]) && array1[mid] == x (mid == 0 || x > array1[mid - 1]) mid == 0 mid 0 x > array1[mid - 1] x array1[mid - 1] array1 mid - 1 mid 1 array1[mid] == x array1[mid] array1 mid x return mid; mid if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n); x > array1[mid] x array1[mid] array1 mid return firstOccurence(array1, (mid + 1), high, x, n); firstOccurence(array1, (mid + 1), high, x, n) firstOccurence array1 (mid + 1) mid 1 high x n return firstOccurence(array1, low, (mid - 1), x, n); firstOccurence(array1, low, (mid - 1), x, n) firstOccurence array1 low (mid - 1) mid 1 x n return -1; -1 1 int array1[] array1 int low low int high high int x x int n n public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	} lastOccurence {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	} if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		} low <= high low high {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		} int mid = low + (high - low) / 2; mid low + (high - low) / 2 low (high - low) / 2 (high - low) high low 2 if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n); (mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x (mid == n - 1 || x < array2[mid + 1]) mid == n - 1 mid n - 1 n 1 x < array2[mid + 1] x array2[mid + 1] array2 mid + 1 mid 1 array2[mid] == x array2[mid] array2 mid x return mid; mid if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n); x < array2[mid] x array2[mid] array2 mid return lastOccurence(array2, low, (mid - 1), x, n); lastOccurence(array2, low, (mid - 1), x, n) lastOccurence array2 low (mid - 1) mid 1 x n return lastOccurence(array2, (mid + 1), high, x, n); lastOccurence(array2, (mid + 1), high, x, n) lastOccurence array2 (mid + 1) mid 1 high x n return -1; -1 1 int array2[] array2 int low low int high high int x x int n n static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	} ruffleSort {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	} int n = a.length; n a.length a a.length for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		} {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		} int oi = random.nextInt(n) oi random.nextInt(n) random.nextInt random n temp = a[oi]; temp a[oi] a oi a[oi] = a[i] a[oi] a oi a[i] a i a[i] = temp a[i] a i temp Arrays.sort(a) Arrays.sort Arrays a int[] a a static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	} InputReader private InputStream stream; stream private byte[] buf = new byte[1024]; buf new byte[1024] 1024 private int curChar; curChar private int numChars; numChars private SpaceCharFilter filter; filter public InputReader(InputStream stream) {
			this.stream = stream;
		} InputReader {
			this.stream = stream;
		} this.stream = stream this.stream this this.stream stream InputStream stream stream public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		} readArrays {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		} int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				arr[i] = scn.nextInt();
			} {
				arr[i] = scn.nextInt();
			} arr[i] = scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn return arr; arr int n n public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		} read {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		} if (numChars == -1)
				throw new InputMismatchException(); numChars == -1 numChars -1 1 throw new InputMismatchException(); new InputMismatchException() if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			} curChar >= numChars curChar numChars {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			} curChar = 0 curChar 0 try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				} catch (IOException e) {
					throw new InputMismatchException();
				} IOException e {
					throw new InputMismatchException();
				} throw new InputMismatchException(); new InputMismatchException() {
					numChars = stream.read(buf);
				} numChars = stream.read(buf) numChars stream.read(buf) stream.read stream buf if (numChars <= 0)
					return -1; numChars <= 0 numChars 0 return -1; -1 1 return buf[curChar++]; buf[curChar++] buf curChar++ curChar public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		} nextInt {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		} int c = read(); c read() read while (isSpaceChar(c))
				c = read(); isSpaceChar(c) isSpaceChar c c = read() c read() read int sgn = 1; sgn 1 if (c == '-') {
				sgn = -1;
				c = read();
			} c == '-' c '-' {
				sgn = -1;
				c = read();
			} sgn = -1 sgn -1 1 c = read() c read() read int res = 0; res 0 do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c)); !isSpaceChar(c) isSpaceChar(c) isSpaceChar c {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} if (c < '0' || c > '9')
					throw new InputMismatchException(); c < '0' || c > '9' c < '0' c '0' c > '9' c '9' throw new InputMismatchException(); new InputMismatchException() res *= 10 res 10 res += c - '0' res c - '0' c '0' c = read() c read() read return res * sgn; res * sgn res sgn public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		} nextLong {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		} int c = read(); c read() read while (isSpaceChar(c))
				c = read(); isSpaceChar(c) isSpaceChar c c = read() c read() read int sgn = 1; sgn 1 if (c == '-') {
				sgn = -1;
				c = read();
			} c == '-' c '-' {
				sgn = -1;
				c = read();
			} sgn = -1 sgn -1 1 c = read() c read() read long res = 0; res 0 do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c)); !isSpaceChar(c) isSpaceChar(c) isSpaceChar c {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} if (c < '0' || c > '9')
					throw new InputMismatchException(); c < '0' || c > '9' c < '0' c '0' c > '9' c '9' throw new InputMismatchException(); new InputMismatchException() res *= 10 res 10 res += c - '0' res c - '0' c '0' c = read() c read() read return res * sgn; res * sgn res sgn public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		} nextLine {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		} int c = read(); c read() read while (isSpaceChar(c))
				c = read(); isSpaceChar(c) isSpaceChar c c = read() c read() read StringBuilder res = new StringBuilder(); res new StringBuilder() do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c)); !isSpaceChar(c) isSpaceChar(c) isSpaceChar c {
				res.appendCodePoint(c);
				c = read();
			} res.appendCodePoint(c) res.appendCodePoint res c c = read() c read() read return res.toString(); res.toString() res.toString res public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		} isSpaceChar {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		} if (filter != null)
				return filter.isSpaceChar(c); filter != null filter null return filter.isSpaceChar(c); filter.isSpaceChar(c) filter.isSpaceChar filter c return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1 c == '\t' c == '\r' c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1 c == ' ' c ' ' c == '\n' c '\n' c == '\r' c '\r' c == '\t' c '\t' c == -1 c -1 1 int c c public String next() {
			return nextLine();
		} next {
			return nextLine();
		} return nextLine(); nextLine() nextLine public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		} SpaceCharFilter public boolean isSpaceChar(int ch); isSpaceChar int ch ch static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	} OutputWriter private final PrintWriter writer; writer public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		} OutputWriter {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		} writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))) writer new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))) OutputStream outputStream outputStream public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		} OutputWriter {
			this.writer = new PrintWriter(writer);
		} this.writer = new PrintWriter(writer) this.writer this this.writer new PrintWriter(writer) Writer writer writer public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		} print {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		} for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			} int i = 0; int i = 0; i 0 i < objects.length i objects.length objects objects.length i++ i++ i {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			} {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			} if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				} i != 0 i 0 {
					writer.print(' ');
					// writer.print(1);
				} writer.print(' ') writer.print writer ' ' writer.print(objects[i]) writer.print writer objects[i] objects i Object... objects objects public void println(Object... objects) {
			print(objects);
			writer.println();
		} println {
			print(objects);
			writer.println();
		} print(objects) print objects writer.println() writer.println writer Object... objects objects public void close() {
			writer.close();
		} close {
			writer.close();
		} writer.close() writer.close writer public class Main {
	static InputReader scn = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	}

	public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	}

	public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	}

	public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	}

	public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	}

	public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	}

	public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}

	public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	}

	public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}

} public class Main {
	static InputReader scn = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	}

	public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	}

	public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	}

	public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	}

	public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	}

	public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	}

	public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}

	public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	}

	public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}

} Main
import java.io.*;
import java.util.*;

public class Main {
	static InputReader scn = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {
		int t = 1;
		while (t-- > 0)
			solve();
		out.close();
	}

	public static void solve() {
		int n = scn.nextInt();
		int max = 0;
		int val = 0;
		while (n-- > 0) {
			int a = scn.nextInt();
			int b = scn.nextInt();
			if (a == b) {
				val++;
				max = Math.max(max, val);
			} else {
				val = 0;
			}
		}
		if (max >= 3)
			out.println("Yes");
		else
			out.println("No");
	}

	public static HashMap<Integer, Integer> CountFrequencies(int[] arr) {
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < arr.length; i++) {
			int a = arr[i];
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		return map;
	}

	public static int countPrimeFactors(int n) {
		int count = 0;
		while (n % 2 == 0) {
			n = n / 2;
			count++;
		}
		for (int i = 3; i <= Math.sqrt(n); i = i + 2) {
			while (n % i == 0) {
				n = n / i;
				count++;
			}
		}
		if (n > 2)
			count++;
		return (count);
	}

	public static int max(int a, int b) {
		if (a >= b)
			return a;
		return b;
	}

	public static int min(int a, int b) {
		if (a <= b)
			return a;
		return b;
	}

	public static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i) + 1 == 0)
				return false;
		}
		return true;
	}

	public static int[] SieveOfEratosthenes(int[] arr) {
		int n = arr.length;
		for (long i = 3; i < n; i = i + 2) {
			arr[(int) i] = 1;
		}
		for (long i = 3; i < n; i = i + 2) {
			if (arr[(int) i] == 1) {
				for (long j = (long) i * i; j < n; j = j + i) {
					arr[(int) j] = 0;
				}
			}
		}
		arr[2] = 1;
		arr[0] = arr[1] = 0;
		return arr;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}

	public static ArrayList<String> printPermutn(String str, String ans, ArrayList<String> list) {
		if (str.length() == 0) {
			list.add(ans);
		}
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			String ros = str.substring(0, i) + str.substring(i + 1);
			printPermutn(ros, ans + ch, list);
		}
		return list;
	}

	public static int binarySearch(int arr[], int l, int r, int x) {
		if (r >= l) {
			int mid = l + (r - l) / 2;
			if (arr[mid] == x)
				return mid;
			if (arr[mid] > x)
				return binarySearch(arr, l, mid - 1, x);
			return binarySearch(arr, mid + 1, r, x);
		}
		return -1;
	}

	public static int firstOccurence(int array1[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == 0 || x > array1[mid - 1]) && array1[mid] == x)
				return mid;
			else if (x > array1[mid])
				return firstOccurence(array1, (mid + 1), high, x, n);
			else
				return firstOccurence(array1, low, (mid - 1), x, n);
		}
		return -1;
	}

	public static int lastOccurence(int array2[], int low, int high, int x, int n) {
		if (low <= high) {
			int mid = low + (high - low) / 2;
			if ((mid == n - 1 || x < array2[mid + 1]) && array2[mid] == x)
				return mid;
			else if (x < array2[mid])
				return lastOccurence(array2, low, (mid - 1), x, n);
			else
				return lastOccurence(array2, (mid + 1), high, x, n);
		}
		return -1;
	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int[] readArrays(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scn.nextInt();
			}
			return arr;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return nextLine();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
					// writer.print(1);
				}
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}
	}

}
