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.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;


import java.util.*;

public class random_num {
public static int mod= (int) (Math.pow(10,9)+7);
	public static void main(String args[]){
		InputReader s= new InputReader(System.in);
		OutputStream outputStream= System.out;
		PrintWriter out= new PrintWriter(outputStream);
		int n = s.nextInt();
		int a = s.nextInt();
		int b = s.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 = s.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){
				System.out.println("YES");
				return;
			}
			if(y3[i]==3||y3[i]==2){
				System.out.println("YES");
				return ;
			}
		}
		System.out.println("NO");
		out.close();
		
	}
	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;
	}
	static class InputReader {
		
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
 
	    public InputReader(InputStream inputstream) {
	      reader = new BufferedReader(new InputStreamReader(inputstream));
	      tokenizer = null;
	    }
	    
	    public String nextLine(){
	    	String fullLine=null;
	    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	              fullLine=reader.readLine();
	            } catch (IOException e) {
	              throw new RuntimeException(e);
	            }
	            return fullLine;
	          }
	          return fullLine;
	    }
		public String next() {
	      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	        try {
	          tokenizer = new StringTokenizer(reader.readLine());
	        } catch (IOException e) {
	          throw new RuntimeException(e);
	        }
	      }
	      return tokenizer.nextToken();
	    }
		public long nextLong() {
		      return Long.parseLong(next());
		    }
	    public int nextInt() {
	      return Integer.parseInt(next());
	    }
	  }
	
	public static HashMap<Integer,Long> getcatalan(int n){
		HashMap<Integer,Long> a=new HashMap<Integer,Long>();
		a.put(0,(long)1);
		for(int i=1;i<=n+1;i++){
			long m=2*(2*i-1);
			long m1=m*a.get(i-1);
			long m3=m1/(i+1);
			//out.println(m+" "+m1+" "+m2+" "+m3);
			
			a.put(i,m3%1000000007);
		}
		return a;
	}
	
	public static int getGdc(int[] x) {
	    // get the smallest of all number no need to check for higher values
	    int smallest = getSmallest(x);

	    for(int i = smallest; i >= 1; i--) {
	       int j;
	       for(j = 0; j < x.length; ++j) {
	           if(x[j] % i != 0)
	               break;
	       }
	       // if we pass through the array with all % == 0 return the value
	       if(j == x.length)
	           return i;
	    }
	    // so the only possible is 1
	    return 1;
	}

	// return smallest number of an array of int
	public static int getSmallest(int[] x) {
	    int smallest = x[0];
	    for(int i = 1; i < x.length; ++i) {
	        if(x[i] < smallest)
	            smallest = x[i];
	    }
	    return smallest;
	}
	public static long gcd(int number1, int number2) {  
		if(number2 == 0){
			return number1;
		} 
		return gcd(number2, number1%number2); 
	}
	
	public static int combinations(int n,int r){
		if(n==r) return 1;
		if(r==1) return n;
		if(r==0) return 1;
		return combinations(n-1,r)+ combinations(n-1,r-1);
	}
	public static long binomialCoeff(int n, int k)
	{
	    long C[][]= new long[n+1][k+1];
	    int i, j;
	 
	    // Caculate value of Binomial Coefficient in bottom up manner
	    for (i = 0; i <= n; i++)
	    {
	        for (j = 0; j <= Math.min(i, k); j++)
	        {
	            // Base Cases
	            if (j == 0 || j == i)
	                C[i][j] = 1;
	 
	            // Calculate value using previosly stored values
	            else
	                C[i][j] = C[i-1][j-1] + C[i-1][j];
	        }
	    }
	 
	    return C[n][k];
	}
	public static long expo(long a, long b){
	    if (b==1)
	        return a;
	    if (b==2)
	        return a*a;

	    if (b%2==0){
	            return expo(expo(a,b/2),2);
	    }
	    else{
	        return a*(expo(expo(a,(b-1)/2),2));
	    }
	}
	
	public static int[] sieve(int N){
		int arr[]= new int[N+1];
		int b[]=new int[N+1];
		for(int i=2;i<Math.sqrt(N);i++){
			if(arr[i]==0){
				
				for(int j= i*i;j<= N;j= j+i){
					arr[j]=1;
				}
			}
		}
		return arr;
		// All the i for which arr[i]==0 are prime numbers.
	}
	static class Pair implements Comparable<Pair>
    {
        int f,s;
        Pair(int ii, int cc)
        {
            f=ii;
            s=cc;
        }
        
        public int compareTo(Pair o) 
        {
            return Integer.compare(this.f, o.f);
        }
        
    }
	public static class company{
		public int t;
		public int d;
		public company(int m,int f){
			this.t=m;
			this.d=f;
		}
		public int get_t(){
			return this.t;
		}
		public int get_d(){
			return this.d;
		}
	}
	public static class pair_comparator implements Comparator<company>{

		@Override
		public int compare(company arg0, company arg1) {
			// TODO Auto-generated method stub
			return arg0.t-arg1.t;
		}
		
	}

}