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.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
//import Queue.node;
public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	static int di = 0,gi = 0;
	public static class Queue{
		private class node{
			int val;
			node next;
			node(int a){
				val = a;
				next = null;
			}
		}
		node head,tail;
		Queue(){
			head = null;
			tail = null;
		}
		public void EnQueue(int a){
			if(head==null){
				node p = new node(a);
				head = p;
				tail = p;
			}
			else{
				node p = new node(a);
				tail.next = p;
				tail = p;
			}
		}
		public int DeQueue(){
			int a = head.val;
			head = head.next;
			return a;
		}
		public boolean isEmpty(){
			return head==null;
		}
	}
	public static void Merge(int a[],int p,int r){
        if(p<r){
            int q = (p+r)/2;
            Merge(a,p,q);
            Merge(a,q+1,r);
            Merge_Array(a,p,q,r);
        }
    }
    public static void Merge_Array(int a[],int p,int q,int r){
        int b[] = new int[q-p+1];
        int c[] = new int[r-q];
        for(int i=0;i<b.length;i++)
            b[i] = a[p+i];
        for(int i=0;i<c.length;i++)
            c[i] = a[q+i+1];
        int i = 0,j = 0;
        for(int k=p;k<=r;k++){
            if(i==b.length){
                a[k] = c[j];
                j++;
            }
            else if(j==c.length){
                a[k] = b[i];
                i++;
            }
            else if(b[i]<c[j]){
                a[k] = b[i];
                i++;
            }
            else{
                a[k] = c[j];
                j++;
            }
        }
    }
    public static void Merge(int a[][],int p,int r){
        if(p<r){
            int q = (p+r)/2;
            Merge(a,p,q);
            Merge(a,q+1,r);
            Merge_Array(a,p,q,r);
        }
    }
    public static void Merge_Array(int a[][],int p,int q,int r){
        int b[][] = new int[q-p+1][2];
        int c[][] = new int[r-q][2];
        for(int i=0;i<b.length;i++){
            b[i][0] = a[p+i][0];
            b[i][1] = a[p+i][1];
        }
        for(int i=0;i<c.length;i++){
            c[i][0] = a[q+i+1][0];
            c[i][1] = a[q+i+1][1];
        }
        int i = 0,j = 0;
        for(int k=p;k<=r;k++){
            if(i==b.length){
                a[k][0] = c[j][0];
                a[k][1] = c[j][1];
                j++;
            }
            else if(j==c.length){
                a[k][0] = b[i][0];
                a[k][1] = b[i][1];
                i++;
            }
            else if(b[i][0]<c[j][0]||(b[i][0]==c[j][0]&&b[i][1]<c[j][1])){
                a[k][0] = b[i][0];
                a[k][1] = b[i][1];
                i++;
            }
            else{
                a[k][0] = c[j][0];
                a[k][1] = c[j][1];
                j++;
            }
        }
    }
    public static void Merge(int a[][],int b[],int p,int r){
        if(p<r){
            int q = (p+r)/2;
            Merge(a,b,p,q);
            Merge(a,b,q+1,r);
            Merge_Array(a,b,p,q,r);
        }
    }
    public static void Merge_Array(int a[][],int xy[],int p,int q,int r){
        int b[][] = new int[q-p+1][2];
        int c[][] = new int[r-q][2];
        for(int i=0;i<b.length;i++){
            b[i][0] = a[p+i][0];
            b[i][1] = a[p+i][1];
        }
        for(int i=0;i<c.length;i++){
            c[i][0] = a[q+i+1][0];
            c[i][1] = a[q+i+1][1];
        }
        int i = 0,j = 0;
        for(int k=p;k<=r;k++){
            if(i==b.length){
                a[k][0] = c[j][0];
                a[k][1] = c[j][1];
                j++;
            }
            else if(j==c.length){
                a[k][0] = b[i][0];
                a[k][1] = b[i][1];
                i++;
            }
            else if(b[i][0]<c[j][0]||(b[i][0]==c[j][0]&&xy[b[i][1]]>xy[c[j][1]])){
                a[k][0] = b[i][0];
                a[k][1] = b[i][1];
                i++;
            }
            else{
                a[k][0] = c[j][0];
                a[k][1] = c[j][1];
                j++;
            }
        }
    }
    public static int pow(int x,int y,long m){
    	if(y==0)
    		return 1;
    	int k = pow(x,y/2,m);
    	if(y%2==0)
    		return (int)((k*(long)k)%m);
    	else
    		return (int)((((k*(long)k)%m)*x)%m);
    }
    static int Inversex = 0,Inversey = 0;
    public static void InverseModulo(int a,int m){
    	if(m==0){
    		Inversex = 1;
    		Inversey = 0;
    	}
    	else{
    		InverseModulo(m,a%m);
    		int temp = Inversex;
    		Inversex = Inversey;
    		Inversey = temp - (a/m)*Inversey;
    	}
    }
    static long mod1 = 1000000007;
    static long mod2 = 1000000009;
	public static long gcd(long a,long b){
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	public static boolean isPrime(long a){
		if(a==1)
			return false;
		else if(a==2||a==3)
			return true;
		for(long i=2;i<=Math.sqrt(a);i++)
			if(a%i==0)
				return true;
		return false;
	}
	public static double distance(int a,int b,int x,int y){
		return Math.sqrt(((long)(a-x)*(long)(a-x))+((long)(b-y)*(long)(b-y)));
	}
	public static void Hash(String a,long b[],long mod){
		for(int i=0;i<a.length();i++)
			b[i+1] = ((26*b[i] + (a.charAt(i)+1)-'a')%mod);
	}
	public static long getHash(long b[],int a,int c,long q,long mod){
		long nm = b[c];
		long p = b[a-1];
		p = ((p*q)%mod);
		return (((nm+mod)-p)%mod);
	}
	public static class Pair implements Comparable<Pair> {
		long u;
		long v;
		BigInteger bi;
		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	public static void set(int x[][],int q,int w,int i,String h[],int x3[]){
		x[i][0] = q;
		x[i][1] = w;
		if(h[0].charAt(0)=='B')
			x3[i] = 1;
		if(h[0].charAt(0)=='R')
			x3[i] = 2;
		if(h[0].charAt(0)=='Q')
			x3[i] = 3;
	}
	private static void soln(){
		int n = nextInt();
		int a = nextInt();
		int b = nextInt();
		int x[][] = new int[4][2];
		int y[][] = new int[4][2];
		int x3[] = new int[4];
		int y3[] = new int[4];
		boolean x1[] = new boolean[4];
		boolean y1[] = new boolean[4];
		int ri=0,qi=0,bi=0;
		while(n-->0){
			String p = nextLine();
			String h[] = p.split(" ");
			int q = Integer.parseInt(h[1]);
			int w = Integer.parseInt(h[2]);
			if(a+b==q+w){
				if(q>=a){
					if(!x1[0]){
						x1[0] = true;
						set(x,q,w,0,h,x3);
					}
					else if(x[0][0]>q)
						set(x,q,w,0,h,x3);
				}
				else{
					if(!x1[1]){
						x1[1] = true;
						set(x,q,w,1,h,x3);
					}
					else if(x[1][0]<q)
						set(x,q,w,1,h,x3);
				}
			}
			else if(a-b==q-w){
				if(q>=a){
					if(!x1[2]){
						x1[2] = true;
						set(x,q,w,2,h,x3);
					}
					else if(x[2][0]>q)
						set(x,q,w,2,h,x3);
				}
				else{
					if(!x1[3]){
						x1[3] = true;
						set(x,q,w,3,h,x3);
					}
					else if(x[3][0]<q)
						set(x,q,w,3,h,x3);
				}
			}
			else if(q==a){
				if(w>=b){
					if(!y1[0]){
						y1[0] = true;
						set(y,q,w,0,h,y3);
					}
					else if(y[0][1]>w)
						set(y,q,w,0,h,y3);
				}
				else{
					if(!y1[1]){
						y1[1] = true;
						set(y,q,w,1,h,y3);
					}
					else if(y[1][1]<w)
						set(y,q,w,1,h,y3);
				}
			}
			else if(w==b){
				if(q>=a){
					if(!y1[2]){
						y1[2] = true;
						set(y,q,w,2,h,y3);
					}
					else if(y[2][0]>q)
						set(y,q,w,2,h,y3);
				}
				else{
					if(!y1[3]){
						y1[3] = true;
						set(y,q,w,3,h,y3);
					}
					else if(y[3][0]<q)
						set(y,q,w,3,h,y3);
				}
			}
		}
		for(int i=0;i<4;i++){
			if(x3[i]==3||x3[i]==1){
				pw.println("YES");
				return;
			}
			if(y3[i]==3||y3[i]==2){
				pw.println("YES");
				return ;
			}
		}
		pw.println("NO");
	}
	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}
	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}
	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
	private static 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++];
	}
	private static 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;
	}
	private static 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;
	}
	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	private static 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();
	}
	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextInt();
		return arr;
	}
	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextLong();
		return arr;
	}
	private static void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr[i] + " ");
		System.out.println();
		return;
	}
	private static void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr[i] + " ");
		System.out.println();
		return;
	}
	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}