Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

type Point struct {
	X, Y int
}

type Gem struct {
	ID int
	Point
}

type Map struct {
	Current       *Point
	Gems          map[int]*Gem
	CollectedGems map[int]*Gem
}

func (m *Map) Move(dir string, l int) {
	switch {
	case dir == "N" || dir == "S":
		a := 1
		if dir == "S" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.Y += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	case dir == "E" || dir == "W":
		a := 1
		if dir == "W" {
			a = -1
		}
		for i := 0; i < l; i++ {
			m.Current.X += a
			for _, g := range m.Gems {
				m.TryToTakeGem(g)
			}
		}
	}
}

func (m *Map) HasCompleted() bool {
	return len(m.Gems) == 0
}

func (m *Map) TryToTakeGem(g *Gem) {
	if m.Current.X == g.X && m.Current.Y == g.Y {
		m.CollectedGems[g.ID] = g
		delete(m.Gems, g.ID)
	}
}

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		m := &Map{
			Current:       &Point{X: 10, Y: 10},
			Gems:          map[int]*Gem{},
			CollectedGems: map[int]*Gem{},
		}
		for i := 0; i < n; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			x, _ := strconv.Atoi(chunks[0])
			y, _ := strconv.Atoi(chunks[1])
			m.Gems[i+1] = &Gem{ID: i + 1, Point: Point{X: x, Y: y}}
		}
		sc.Scan()
		opCnt, _ := strconv.Atoi(sc.Text())
		for i := 0; i < opCnt; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			dir := chunks[0]
			v, _ := strconv.Atoi(chunks[1])
			m.Move(dir, v)
		}
		msg := "No"
		if m.HasCompleted() {
			msg = "Yes"
		}
		fmt.Println(msg)
	}
}

C++: // AOJ 2000 "Misterious Gems" (ICPC模擬国内予選 2006 Problem A)
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    while (true) {
        int field[21][21]; // フィールドの縦、横の座標
        int N; // 宝石の個数
        int M; // 命令の個数
        int positionX = 10; // ロボットの位置のx座標
        int positionY = 10; // ロボットの位置のy座標
        int dx[] = {0, 1, 0, -1};
        int dy[] = {1, 0, -1, 0};
        memset(field, 0, sizeof(field));
        
        cin >> N;
        if (N == 0) {
            break;
        }
        for (int i = 0; i < N; i++) {
            int x, y;
            cin >> x >> y;
            field[y][x] = 1;
        }
        
        cin >> M;
        for (int i = 0; i < M; i++) {
            char direction;
            int dir;
            int distance;
            cin >> direction >> distance;
            switch (direction) {
            case 'N':
                dir = 0;
                break;
            case 'E':
                dir = 1;
                break;
            case 'S':
                dir = 2;
                break;
            case 'W':
                dir = 3;
                break;
            }
            for (int j = 0; j < distance; j++) {
                positionX += dx[dir];
                positionY += dy[dir];
                field[positionY][positionX] = 0;
            }
        }
        
        bool ans = true;
        for (int i = 0; i < 21; i++) {
            for (int j = 0; j < 21; j++) {
                if (field[i][j] == 1) {
                    ans = false;
                }
            }
        }
        if (ans) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <string.h>

char a[21][21];

int main()
{
  int n,x,y,m,s;
  int i;
  char d[3];

  while(1){
    scanf("%d", &n);
    if(n==0)
      break;

    memset(a,0,sizeof(a));

    for(i=0;i<n;i++){
      scanf("%d%d", &x, &y);
      a[x][y]=1;
    }

    scanf("%d", &m);
    x=10,y=10;
    while(m-- > 0){
      scanf("%s%d", d, &s);
      while(s-- > 0){
	if(d[0] == 'E')x++;
	else if(d[0] == 'S')y--;
	else if(d[0] == 'W')x--;
	else if(d[0] == 'N')y++;
	
	if(a[x][y])n--,a[x][y]=0;
      }
    }

    if(n==0)
      printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

C++: //Mysterious Gems
#include<cstdio>

int now_x, now_y;
int n;
int map[21][21];
int vector[4][2]={{0,1}, {1,0}, {0,-1}, {-1,0}};

void init_map(){
	now_x=now_y=10;
	n=0;
	for(int i=0; i<21; i++)
		for(int j=0; j<21; j++)
			map[i][j]=0;
}

void go(char dir, int dis){
	int d;
	if(dir=='N')d=0;
	else if(dir=='E')d=1;
	else if(dir=='S')d=2;
	else if(dir=='W')d=3;

	for(int i=0; i<dis; i++){
		now_x+=vector[d][0];
		now_y+=vector[d][1];
		if(map[now_y][now_x]==1){
			n++;
			map[now_y][now_x]=0;
		}
	}
}

int main(){
	int N, M;
	while(true){
		scanf("%d", &N);
		if(N==0)break;
		init_map();
		for(int i=0; i<N; i++){
			int x, y;
			scanf("%d %d", &x, &y);
			map[y][x]=1;
		}
		scanf("%d", &M);
		for(int i=0; i<M; i++){
			char dir;
			int dis;
			scanf(" %c %d", &dir, &dis);
			go(dir, dis);
		}
		if(N==n) puts("YES");
		else puts("NO");
	}
	return 0;
}

C++: #include <iostream>
#define N 21
using namespace std;

int main(){
  int n,m,x,y,rx,ry,l,cnt,d[N][N];
  char c;
  while(1){
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) d[i][j]=0;
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;i++) cin>>x>>y,d[N-y-1][x]=1;
    cin>>m;
    rx=ry=10;
    cnt=0;
    while(m--){
      cin>>c>>l;
      while(l--){
	if(c=='N') ry--;
	if(c=='E') rx++;
	if(c=='S') ry++;
	if(c=='W') rx--;
	if(d[ry][rx]) d[ry][rx]=0,cnt++;
      }
    }
    if(cnt==n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  while(N != 0){
    vector<int> X(N),Y(N);
    vector<bool> get(N,false); 
    for(int i=0; i<N; i++){
      cin >> X[i] >> Y[i];
    }
    int M;
    cin >> M;
    int x=10,y=10;
    string str = "ENWS";
    for(int i=0; i<M; i++){
      char c;
      int cnt;
      cin >> c >> cnt;
      for(int dir=0; dir<4; dir++){
        if(str[dir] == c){
          for(int k=0; k<cnt; k++){
            x += dx[dir];
            y += dy[dir];
            for(int j=0; j<N; j++){
              if(X[j] == x and Y[j] == y){
                get[j] = true;
              }
            }
          }
        }
      }
    }
    bool all = true;
    for(int i=0; i<N; i++){
      if(!get[i]) all = false;
    }
    if(all){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    cin >> N;
  }
  return 0;
}