Under construction

Still being built. Things may change

Mysterious Gems

Interview

Time limit8sMemory limit512 MB

Summary
Simulate a robot starting at (10,10) that walks axis-aligned segments and check whether every given gem lies on some segment or its endpoint.
Level

Easy3 of 10

Topics
Simulation, Implementation, Array
Solved
No attempts yet

Problem

From star year 1603 to 1867, people called that era the EDO era. EDO refers to Enhanced Driving Operation, the most advanced space navigation technology of the time, developed by Dr. Izy in 1603.

You are a space adventurer, flying through space and exploring various planets. During one of your adventures, you discovered a very strange planet. On that planet, mysterious gems shining in seven colors lay scattered everywhere. You thought about descending to the planet, but you learned that a serious problem made this impossible. The planet's air contained a deadly poison that kills a human instantly on contact.

So you came up with the idea of collecting the gems with a robot. You wait in orbit around the planet. Then you remotely control the robot you sent down to collect the gems. You control the robot with a sequence of commands, each consisting of a pair of a direction to move and a distance to move. When the robot finds gems along its movement path (including the destination), it collects all of them.

Your job is to write a program that determines whether the robot has collected all the gems when it finishes executing all the given commands.

The range in which the robot collects the mysterious gems is not very wide. Therefore, the entire range in which the robot moves can be represented on a two-dimensional plane. The range in which the robot moves is the interior (including the boundary) of the square whose lower-left corner is (0,0) and whose upper-right corner is (20,20). The robot always descends to the center of the range, that is, the coordinate (10,10). Also, all gems are guaranteed to lie on lattice points other than the center.

Input

The input consists of multiple data sets.

The first line of each data set contains a single positive integer N (1 ≤ N ≤ 20). This represents the number of mysterious gems within the range in which the robot can move. The next N lines each contain xi and yi (0 ≤ xi, yi ≤ 20), which represent the coordinates where the i-th mysterious gem lies. No two gems lie in the same place.

The next line contains a single integer M (1 ≤ M ≤ 30), which represents the number of commands given to the robot. The following M lines each contain dj and a single positive integer lj. These represent the direction and the distance of the j-th command. The direction is one of the characters N, E, S, W, representing north, east, south, and west, in that order (north is the positive direction of the y-axis, east is the positive direction of the x-axis). It is guaranteed that no command takes the robot outside the range in which it can move.

The input ends when N = 0, and this data set is not included in the input.

Output

For each data set, output "Yes" on a single line if the robot can collect all the gems, and "No" otherwise.

Examples1

  1. Example 1

    Input
    2
    10 11
    11 12
    2
    N 2
    E 1
    2
    10 11
    11 12
    2
    N 2
    W 1
    3
    0 15
    5 10
    5 15
    5
    W 10
    S 10
    N 20
    E 10
    S 10
    0
    
    Expected output
    Yes
    No
    No