Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead.

The first task he faced is to check whether the king is in check. Anton doesn't know how to implement this so he asks you to help.

Consider that an infinite chess board contains one white king and the number of black pieces. There are only rooks, bishops and queens, as the other pieces are not supported yet. The white king is said to be in check if at least one black piece can reach the cell with the king in one move. 

Help Anton and write the program that for the given position determines whether the white king is in check.

Remainder, on how do chess pieces move: 

  * Bishop moves any number of cells diagonally, but it can't "leap" over the occupied cells. 
  * Rook moves any number of cells horizontally or vertically, but it also can't "leap" over the occupied cells. 
  * Queen is able to move any number of cells horizontally, vertically or diagonally, but it also can't "leap". 

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 500 000) — the number of black pieces.

The second line contains two integers x0 and y0 ( - 109 ≤ x0, y0 ≤ 109) — coordinates of the white king.

Then follow n lines, each of them contains a character and two integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — type of the i-th piece and its position. Character 'B' stands for the bishop, 'R' for the rook and 'Q' for the queen. It's guaranteed that no two pieces occupy the same position.

Output

The only line of the output should contains "YES" (without quotes) if the white king is in check and "NO" (without quotes) otherwise.

Examples

Input

2
4 2
R 1 1
B 1 5


Output

YES


Input

2
4 2
R 3 3
B 1 5


Output

NO

Note

Picture for the first sample: 

<image> White king is in check, because the black bishop can reach the cell with the white king in one move. The answer is "YES".

Picture for the second sample: 

<image> Here bishop can't reach the cell with the white king, because his path is blocked by the rook, and the bishop cant "leap" over it. Rook can't reach the white king, because it can't move diagonally. Hence, the king is not in check and the answer is "NO".
import java.util.Arrays;
import java.util.InputMismatchException;

import java.io.IOException;
import java.io.PrintWriter;

public class D_379 {
	public static int mod = 1000000007;
	static FastReader scan = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String args[]) {
		/******************* code ***********************/
		int n = scan.nextInt();
		long x = scan.nextLong();
		long y = scan.nextLong();
	
		Pair King = new Pair(x, y, '0');
		Pair arr[] = new Pair[n];
		Pair s1 = null;
		Pair s2 = null;
		Pair s3 = null;
		Pair s4 = null;
		Pair s5 = null;
		Pair s6 = null;
		Pair s7 = null;
		Pair s8 = null;
		double d1 = Long.MAX_VALUE;
		double d2 = Long.MAX_VALUE;
		double d3 = Long.MAX_VALUE;
		double d4 = Long.MAX_VALUE;
		double d5 = Long.MAX_VALUE;
		double d6 = Long.MAX_VALUE;
		double d7 = Long.MAX_VALUE;
		double d8 = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			String s[] = scan.nextLine().split(" ");

			arr[i] = new Pair(Long.parseLong(s[1]), Long.parseLong(s[2]), s[0].charAt(0));
			if (arr[i].y == y) {
				if (x > arr[i].x) {
					//1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1
					if (s1 == null) {
						s1 = arr[i];
						d1 = distance(King, arr[i]);
					} else {
						double temp = distance(King, arr[i]);
						if (temp < d1) {
							d1 = temp;
							s1 = arr[i];
						}
					}

				} else {
					//2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2
					if (s2 == null) {
						s2 = arr[i];
						d2 = distance(King, arr[i]);
					} else {
						double temp = distance(King, arr[i]);
						if (temp < d2) {
							d2 = temp;
							s2 = arr[i];
						}
					}

				}
			} else if (arr[i].x == x) {
				if (y > arr[i].y) {
					//3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3
					if (s3 == null) {
						s3 = arr[i];
						d3 = distance(King, arr[i]);
					} else {
						double temp = distance(King, arr[i]);
						if (temp < d3) {
							s3 = arr[i];
							d3 = temp;
						}
					}

				} else {
					//4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx4
					if (s4 == null) {
						s4 = arr[i];
						d4 = distance(King, arr[i]);
					} else {
						double temp = distance(King, arr[i]);
						if (temp < d4) {
							s4 = arr[i];
							d4 = temp;
						}
					}

				}
			} else if (Math.abs(arr[i].x - x) == Math.abs(arr[i].y - y)) {
				if (x - arr[i].x > 0) {
					if (y - arr[i].y > 0) {
						//5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5
						if (s5 == null) {
							s5 = arr[i];
							d5 = distance(King, arr[i]);
						} else {
							double temp = distance(King, arr[i]);
							if (temp < d5) {
								s5 = arr[i];
								d5 = temp;
							}
						}
					} else {
						//6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6
						if (s6 == null) {
							s6 = arr[i];
							d6 = distance(King, arr[i]);
						} else {
							double temp = distance(King, arr[i]);
							if (temp < d6) {
								s6 = arr[i];
								d6 = temp;
							}
						}
					}
				} else {

					if (y - arr[i].y > 0) {
						//7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7
						if (s7 == null) {
							s7 = arr[i];
							d7 = distance(King, arr[i]);
						} else {
							double temp = distance(King, arr[i]);
							if (temp < d7) {
								s7 = arr[i];
								d7 = temp;
							}
						}
					} else {
						//8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx8
						if (s8 == null) {
							s8 = arr[i];
							d8 = distance(King, arr[i]);
						} else {
							double temp = distance(King, arr[i]);
							if (temp < d8) {
								s8 = arr[i];
								d8 = temp;
							}
						}
					}
				}
			}

		}
		int flag = 0;
		if (s1 != null && (s1.c == 'R' || s1.c == 'Q'))
			flag = 1;
		if (s2 != null && (s2.c == 'R' || s2.c == 'Q'))
			flag = 1;
		if (s3 != null && (s3.c == 'R' || s3.c == 'Q'))
			flag = 1;
		if (s4 != null && (s4.c == 'R' || s4.c == 'Q'))
			flag = 1;
		if (s5 != null && (s5.c == 'B' || s5.c == 'Q'))
			flag = 1;
		if (s6 != null && (s6.c == 'B' || s6.c == 'Q'))
			flag = 1;
		if (s7 != null && (s7.c == 'B' || s7.c == 'Q'))
			flag = 1;
		if (s8 != null && (s8.c == 'B' || s8.c == 'Q'))
			flag = 1;
		if (flag == 1)
			out.println("YES");
		else
			out.println("NO");

		out.close();

	}

	public static double distance(Pair a, Pair b) {
		double ans =  Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
		return ans;
	}

	static class Pair implements Comparable<Pair> {
		long x;
		long y;
		char c;

		Pair(long xx, long yy, char cc) {
			x = xx;
			y = yy;
			c = cc;
		}

		@Override
		public int compareTo(Pair o) {
			if (Long.compare(this.y, o.y) != 0)
				return Long.compare(this.y, o.y);
			else
				return Long.compare(this.x, o.x);
		}
	}

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static long pow(long x, long n, long mod) {
		long res = 1;
		x %= mod;
		while (n > 0) {
			if (n % 2 == 1) {
				res = (res * x) % mod;
			}
			x = (x * x) % mod;
			n /= 2;
		}
		return res;
	}

	/************** Scanner ********************/
	static class FastReader {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

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

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

		public String nextString() {
			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 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 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 int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

}
