#P3490. Jumping Frogs

Jumping Frogs

Description

Recently, Lambert has been interested in a Flash game called Jumping Frogs. The game proceeds as follows. On r-by-c grid board, there n frogs each occupying a separate cell. In each move, a frog jumps in one of the eight rectilinear and diagonal directions, flies over a neighboring frog, and lands in an empty cell at a distance of two. The frog having been flown over is then removed from the board. The goal is to remove all but one frog.

After a few attempts, Lambert finds the game too difficult for him. Therefore, he finds himself a slightly different version of the game, which allows a frog to jump to an empty cell at a distance of three without removing any other frogs from the board. To compensate such a reduction in difficulty, it is additionally required that an ending cell be specified by the player before the game starts. Upon completion of the game, the remaining frog is required to be in the ending cell. With relaxed rules of jumping, Lambert is now able to remove all but one frog. But sometimes he finds that he cannot place that remaining frog in the specified ending cell. Given a starting configuration of the game and the ending cell specified by Lambert, can you tell whether the game can be completed?

Input

The input contains multiple test cases. Each test case begins with a line containing five positive integers n, r, c, x and y (n ≤ 10; 3 ≤ r, c ≤ 10; xr; yc). Lambert specifies the cell in the x-th row and y-th column as the ending cell. Then come n lines each containing a pair of positive integers xi and yi (xir; yic), indicating a frog in the cell in the xi-row and yi-column. The input ends once EOF is met.

Output

For each test case, output one line containing “Yes” if the game can be completed or “No” otherwise.

2 3 3 1 1
2 2
3 3
2 3 3 1 1
1 1
2 2
Yes
No

Source

POJ Founder Monthly Contest – 2008.01.31

, xfxyjwf