734_D. Anton and Chess
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".
```python
MAX_NUM = 10**9
n = int(input())
king_x, king_y = [int(x) for x in input().split()]
nomakers = {'Rook': {'right-down':[], 'right-up':[], 'left-down':[], 'left-up':[]}, 'Bishop': {'left':[], 'right':[], 'up':[], 'down':[]}}
yes = {'Queen':{'right-down':[], 'right-up':[], 'left-down':[], 'left-up':[],'left':[], 'right':[], 'up':[], 'down':[]},'Bishop': {'right-down':[], 'right-up':[], 'left-down':[], 'left-up':[]}, 'Rook': {'left':[], 'right':[], 'up':[], 'down':[]}}
for i in range(n):
    figure, figure_x, figure_y = input().split()
    figure_x, figure_y = [int(x) for x in [figure_x, figure_y]]
    if figure == 'Q':
        if figure_x == king_x:
            if figure_y < king_y: half = 'down'
            else: half = 'up'
            yes['Queen'][half].append(abs(king_y - figure_y))
            for i in range(len(nomakers['Bishop'][half])):
                if nomakers['Bishop'][half][i]<yes['Queen'][half][-1]:
                    del yes['Queen'][half][-1]
                    break
        elif figure_y == king_y:
            if figure_x < king_x: half = 'left'
            else: half = 'right'
            yes['Queen'][half].append(abs(king_x - figure_x))
            for i in range(len(nomakers['Bishop'][half])):
                if nomakers['Bishop'][half][i]<yes['Queen'][half][-1]:
                    del yes['Queen'][half][-1]
                    break
        elif abs(figure_x - king_x) == abs(figure_y - king_y):
            if figure_x > king_x:
                if figure_y > king_y: quarter = 'right-up'
                else: quarter = 'right-down'
            else:
                if figure_y > king_y: quarter = 'left-up'
                else: quarter = 'left-down'
            yes['Queen'][quarter].append(abs(king_x - figure_x))
            for i in range(len(nomakers['Rook'][quarter])):
                if nomakers['Rook'][quarter][i]<yes['Queen'][quarter][-1]:
                    del yes['Queen'][quarter][-1]
                    break
    elif figure == 'R':
        if figure_x == king_x:
            if figure_y < king_y: half = 'down'
            else: half = 'up'
            yes['Rook'][half].append(abs(king_y - figure_y))
            for i in range(len(nomakers['Bishop'][half])):
                if nomakers['Bishop'][half][i]<yes['Rook'][half][-1]:
                    del yes['Rook'][half][-1]
                    break
        elif figure_y == king_y:
            if figure_x > king_x: half = 'right'
            else: half = 'left'
            yes['Rook'][half].append(abs(king_x - figure_x))
            for i in range(len(nomakers['Bishop'][half])):
                if nomakers['Bishop'][half][i]<yes['Rook'][half][-1]:
                    del yes['Rook'][half][-1]
                    break
        elif abs(figure_x - king_x) == abs(figure_y - king_y):
            if figure_x > king_x:
                if figure_y > king_y: quarter = 'right-up'
                else: quarter = 'right-down'
            else:
                if figure_y > king_y: quarter = 'left-up'
                else: quarter = 'left-down'
            nomakers['Rook'][quarter].append(abs(figure_x - king_x))
            i = 0
            n = len(yes['Queen'][quarter])
            while i < n:
                element = yes['Queen'][quarter][i]
                if nomakers['Rook'][quarter][-1] < element:
                    del yes['Queen'][quarter][i]
                    n = n - 1
                else:
                    i = i + 1
            i = 0
            n = len(yes['Bishop'][quarter])
            while i < n:
                element = yes['Bishop'][quarter][i]
                if nomakers['Rook'][quarter][-1] < element:
                    del yes['Bishop'][quarter][i]
                    n = n - 1
                else:
                    i = i + 1
    else:
        if abs(figure_x - king_x) == abs(figure_y - king_y):
            if figure_x > king_x:
                if figure_y > king_y: quarter = 'right-up'
                else: quarter = 'right-down'
            else:
                if figure_y > king_y: quarter = 'left-up'
                else: quarter = 'left-down'
            yes['Bishop'][quarter].append(abs(figure_x - king_x))
            for i in range(len(nomakers['Rook'][quarter])):
                if nomakers['Rook'][quarter][i] < yes['Bishop'][quarter][-1]:
                    del yes['Bishop'][quarter][-1]
                    break
        elif figure_x == king_x or figure_y == king_y:
            if figure_y < king_y:
                a = figure_y - king_y
                half = 'down'
            elif figure_y > king_y:
                half = 'up'
                a = figure_y - king_y
            elif figure_x > king_x:
                a = figure_x - king_x
                half = 'right'
            else:
                a = figure_x - king_x
                half = 'left'
            nomakers['Bishop'][half].append(abs(a))
            i = 0
            n = len(yes['Rook'][half])
            while i < n:
                element = yes['Rook'][half][i]
                if nomakers['Bishop'][half][-1] < element:
                    del yes['Rook'][half][i]
                    n = n - 1
                else:
                    i = i + 1
            i = 0
            n = len(yes['Queen'][half])
            while i < n:
                element = yes['Queen'][half][i]
                if nomakers['Bishop'][half][-1] < element:
                    del yes['Queen'][half][i]
                    n = n - 1
                else:
                    i = i + 1
if len(yes['Queen']['left']) > 0 or len(yes['Queen']['right']) > 0 or len(yes['Queen']['down']) > 0 or len(yes['Queen']['up']) > 0 or len(yes['Queen']['left-up']) > 0 or len(yes['Queen']['left-down']) > 0 or len(yes['Queen']['right-up']) > 0 or len(yes['Queen']['right-down']) > 0 or len(yes['Bishop']['right-down']) > 0 or len(yes['Bishop']['right-up']) > 0 or len(yes['Bishop']['left-up']) > 0 or len(yes['Bishop']['left-down']) > 0 or len(yes['Rook']['left']) > 0 or len(yes['Rook']['right']) > 0 or len(yes['Rook']['up']) > 0 or len(yes['Rook']['down']) > 0:
    print("YES")
else: print("NO")
```