alexjercan/bugnet huggingface dataset:
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
#define FOR(i, a) for (int i = 0; i < a; i++)
int a[21][21];
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    FOR(i, 21) {
      FOR(j, 21) { a[i][j] = 0; }
    }
    FOR(i, n) {
      int d, f;
      cin >> d >> f;
      a[f][d]++;
    }
    int m;
    cin >> m;
    int x = 10;
    int y = 10;
    a[10][10] = 0;
    FOR(i, m) {
      char p;
      int move;
      cin >> p >> move;
      int h;
      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};
      if (p == 'N') {
        h = 0;
      } else if (p == 'E') {
        h = 1;
      } else if (p == 'S') {
        h = 2;
      } else if (p == 'W') {
        h = 3;
      }
      FOR(j, move) {
        x += dx[h];
        y += dy[h];
        a[x][y] = 0;
      }
    }
    int ans = 0;
    FOR(i, 21) {
      FOR(j, 21) {
        if (a[i][j] != 0) {
          ans++;
        }
      }
    }
    if (ans == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
#define FOR(i, a) for (int i = 0; i < a; i++)
int a[20][20];
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    FOR(i, 20) {
      FOR(j, 20) { a[i][j] = 0; }
    }
    FOR(i, n) {
      int d, f;
      cin >> d >> f;
      a[d - 1][f - 1]++;
    }
    int m;
    cin >> m;
    int x = 9;
    int y = 9;
    a[9][9] = 0;
    FOR(i, m) {
      char p;
      int move;
      cin >> p >> move;
      int h;
      int dy[4] = {1, 0, -1, 0};
      int dx[4] = {0, 1, 0, -1};
      if (p == 'N') {
        h = 1;
      } else if (p == 'E') {
        h = 2;
      } else if (p == 'S') {
        h = 3;
      } else {
        h = 4;
      }
      FOR(j, move) {
        x += dx[i];
        y += dy[i];
        a[x][y] = 0;
        cout << x << " " << y << endl;
      }
    }
    int ans = 0;
    FOR(i, 20) {
      FOR(j, 20) {
        if (a[i][j] != 0) {
          ans++;
        }
      }
    }
    if (ans == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  while (cin >> N && N) {
    int a[21][21] = {};
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      a[y][x] = 1;
    }
    int M;
    cin >> M;
    int x = 10, y = 10;
    for (int i = 0; i < M; i++) {
      int z;
      char h;
      cin >> h >> z;
      for (int k = 0; k < z; k++) {
        if (h == 'E') {
          x++;
        } else if (h == 'W') {
          x--;
        } else if (h == 'N') {
          y++;
        } else {
          y--;
        }
        a[y][x] = 0;
      }
    }
    int count = 0;
    for (int i = 0; i < 21; i++) {
      for (int j = 0; j < 21; j++) {
        count += a[i][j];
      }
    }
    if (count == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  while (cin >> N && N) {
    int a[20][20] = {};
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      a[y][x] = 1;
    }
    int M;
    cin >> M;
    int x = 10, y = 10;
    for (int i = 0; i < M; i++) {
      int z;
      char h;
      cin >> h >> z;
      for (int k = 0; k < z; k++) {
        if (h == 'E') {
          x++;
        } else if (h == 'W') {
          x--;
        } else if (h == 'N') {
          y++;
        } else {
          y--;
        }
        a[y][x] = 0;
      }
    }
    int count = 0;
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        count += a[i][j];
      }
    }
    if (count == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

bool field[21][21];

void initialize() {
  REP(i, 21) {
    REP(j, 21) { field[i][j] = false; }
  }
}

int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    initialize();
    REP(k, n) {
      int x, y;
      cin >> x >> y;
      field[y][x] = true;
    }

    int m;
    int i = 10, j = 10, cnt = 0;
    cin >> m;
    REP(k, m) {
      char direct;
      int dist;
      cin >> direct >> dist;
      REP(l, dist) {
        switch (direct) {
        case 'E':
          j++;
          break;
        case 'W':
          j--;
          break;
        case 'N':
          i++;
          break;
        case 'S':
          i--;
          break;
        }
        if (field[i][j]) {
          cnt++;
          field[i][j] = false;
        }
      }
    }
    if (cnt == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int field[21][21];

void initialize() {
  REP(i, 21) {
    REP(j, 21) { field[i][j] = 0; }
  }
}

int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    initialize();
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      field[x][y] = 1;
    }
    int m;
    int i = 10, j = 10, cnt = 0;
    cin >> m;
    REP(k, m) {
      char direct;
      int dist;
      cin >> direct >> dist;
      switch (direct) {
      case 'E':
        for (; i <= i + dist; i++) {
          if (field[i][j] = 1) {
            cnt++;
            field[i][j] = 0;
          }
        }
        break;
      case 'W':
        for (; i <= i - dist; i--) {
          if (field[i][j] = 1) {
            cnt++;
            field[i][j] = 0;
          }
        }
        break;
      case 'N':
        for (; j <= j + dist; j++) {
          if (field[i][j] = 1) {
            cnt++;
            field[i][j] = 0;
          }
        }
        break;
      case 'S':
        for (; j <= j - dist; j--) {
          if (field[i][j] = 1) {
            cnt++;
            field[i][j] = 0;
          }
        }
        break;
      }
    }
    if (cnt == n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int grid[21][21];
int nowx, nowy;
void init() {
  nowx = 10, nowy = 10;
  for (int i = 0; i <= 20; i++) {
    for (int j = 0; j <= 20; j++) {
      grid[j][i] = 0;
    }
  }
}

void serch(int a, int b, int f) {
  if (a > b)
    swap(a, b);
  if (f == 1) {
    for (int i = a; i <= b; i++)
      grid[nowx][i] = 0;
  } else {
    for (int i = a; i <= b; i++)
      grid[i][nowy] = 0;
  }
}

bool check() {
  bool flag = true;
  for (int i = 0; i <= 20; i++) {
    for (int j = 0; j <= 20; j++) {
      if (grid[j][i] == 1) {
        flag = false;
        goto N;
      }
    }
  }
N:;
  if (flag)
    return true;
  else
    return false;
}

int main() {
  int n;
  while (cin >> n, n) {
    init();
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      grid[x][y] = 1;
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      char c;
      int move, f = 0, past;
      cin >> c >> move;
      if (c == 'N') {
        f = 1;
        past = nowy;
        nowy += move;
      } else if (c == 'S') {
        f = 1;
        past = nowy;
        nowy -= move;
      } else if (c == 'E') {
        past = nowx;
        nowx += move;
      } else {
        past = nowx;
        nowx -= move;
      }
      if (f == 0)
        serch(past, nowx, f);
      else
        serch(past, nowy, f);
    }
    if (check())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int grid[21][21];
int nowx = 10, nowy = 10;
void init() {
  for (int i = 0; i <= 20; i++) {
    for (int j = 0; j <= 20; j++) {
      grid[j][i] = 0;
    }
  }
}

void serch(int a, int b, int f) {
  if (a > b)
    swap(a, b);
  cout << a << ' ' << b << endl;
  if (f == 1) {
    for (int i = a; i <= b; i++)
      grid[nowx][i] = 0;
  } else {
    for (int i = a; i <= b; i++)
      grid[i][nowy] = 0;
  }
}

bool check() {
  bool flag = true;
  for (int i = 0; i <= 20; i++) {
    for (int j = 0; j <= 20; j++) {
      if (grid[j][i] == 1) {
        flag = false;
        goto N;
      }
    }
  }
N:;
  if (flag)
    return true;
  else
    return false;
}

int main() {
  int n;
  while (cin >> n, n) {
    init();
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      grid[x][y] = 1;
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      char c;
      int move, f = 0, past;
      cin >> c >> move;
      if (c == 'N') {
        f = 1;
        past = nowy;
        nowy += move;
      } else if (c == 'S') {
        f = 1;
        past = nowy;
        nowy -= move;
      } else if (c == 'E') {
        past = nowx;
        nowx += move;
      } else {
        past = nowx;
        nowx -= move;
      }
      if (f == 0)
        serch(past, nowx, f);
      else
        serch(past, nowy, f);
    }
    if (check())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#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;
}

Error: WA

Fixed submission:

#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;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

#define SPACE 21

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    int x, y;
    vector<vector<bool>> field(SPACE, vector<bool>(SPACE, false));
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      field[x][y] = true;
    }

    int m, l, d_int;
    char d;
    cin >> m;
    x = y = 10;
    for (int i = 0; i < m; i++) {
      cin >> d >> l;
      switch (d) {
      case 'N':
        d_int = 0;
        break;
      case 'E':
        d_int = 1;
        break;
      case 'S':
        d_int = 2;
        break;
      case 'W':
        d_int = 3;
        break;
      }

      for (int j = 0; j < l; j++) {
        x += dx[d_int];
        y += dy[d_int];
        if (field[x][y]) {
          field[x][y] = false;
          --n;
        }
      }
    }

    if (n == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

#define SPACE 20

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }

    int x, y;
    vector<vector<bool>> field(SPACE, vector<bool>(SPACE, false));
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      field[x][y] = true;
    }

    int m, l, d_int;
    char d;
    cin >> m;
    x = y = 10;
    for (int i = 0; i < m; i++) {
      cin >> d >> l;
      switch (d) {
      case 'N':
        d_int = 0;
        break;
      case 'E':
        d_int = 1;
        break;
      case 'S':
        d_int = 2;
        break;
      case 'W':
        d_int = 3;
        break;
      }

      for (int j = 1; j <= l; j++) {
        x += dx[d_int];
        y += dy[d_int];
        if (field[x][y]) {
          field[x][y] = false;
          --n;
        }
      }
    }

    if (n == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)

int main() {
  int n, o;
  while (cin >> n, n) {
    int v[25][25] = {{}};
    int x, y;
    rep(i, n) {
      cin >> x >> y;
      v[x][y] = 1;
    }
    int ans = 0;
    cin >> o;
    x = 10, y = 10;
    int d;
    string s;
    rep(i, o) {
      cin >> s >> d;
      if (s == "W") {
        rep(j, d) {
          --x;
          ans += v[x][y];
          v[x][y] = 0;
        }
      }
      if (s == "E") {
        rep(j, d) {
          ++x;
          ans += v[x][y];
          v[x][y] = 0;
        }
      }
      if (s == "S") {
        rep(j, d) {
          --y;
          ans += v[x][y];
          v[x][y] = 0;
        }
      }
      if (s == "N") {
        rep(j, d) {
          ++y;
          ans += v[x][y];
          v[x][y] = 0;
        }
      }
      /* cout << ans << endl; */
    }
    if (ans == n) {
      cout << "Yes" << endl;
    } else
      cout << "No" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)

int main() {
  int n, o;
  while (cin >> n, n) {
    int v[25][25] = {{}};
    int x, y;
    rep(i, n) {
      cin >> x >> y;
      v[x][y] = 1;
    }
    int ans = 0;
    cin >> o;
    x = 10, y = 10;
    int d;
    string s;
    rep(i, o) {
      cin >> s >> d;
      if (s == "W") {
        for (int j = x + d - 1; j > x; --j) {
          ans += v[j][y];
          v[j][y] = 0;
        }
        x -= d;
      }
      if (s == "E") {
        for (int j = x; j <= x + d; ++j) {
          ans += v[j][y];
          v[j][y] = 0;
        }
        x += d;
      }
      if (s == "S") {
        for (int j = y + d - 1; j > y; --j) {
          ans += v[x][j];
          v[x][j] = 0;
        }
        y -= d;
      }
      if (s == "N") {
        for (int j = y; j <= y + d; ++j) {
          ans += v[x][j];
          v[x][j] = 0;
        }
        y += d;
      }
      /* cout << x << ' ' << y << endl; */
    }
    if (ans == n) {
      cout << "Yes" << endl;
    } else
      cout << "No" << endl;
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m, x, y, mer;
  char dim;
  cin >> n;
  vector<int> ans;
  while (n) {
    vector<vector<int>> gem(21, vector<int>(21));
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      gem[y][x] = 1;
    }
    cin >> m;
    int nowx = 10;
    int nowy = 10;
    for (int j = 0; j < m; j++) {
      cin >> dim >> mer;
      for (int k = 1; k <= mer; k++) {
        if (dim == 'N')
          nowy++;
        if (dim == 'E')
          nowx++;
        if (dim == 'S')
          nowy--;
        if (dim == 'W')
          nowx--;
        gem[nowy][nowx] = 0;
      }
    }
    int boo = 0;
    for (int i = 0; i <= 20; i++) {
      for (int j = 0; j <= 20; j++) {
        if (gem[i][j])
          boo = 1;
      }
    }
    ans.push_back(boo);
    cin >> n;
  }
  for (int i = 0; i < (int)ans.size(); i++) {
    if (!ans[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Error: 0

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m, x, y, mer;
  char dim;
  cin >> n;
  vector<int> ans;
  while (n) {
    vector<vector<int>> gem(21, vector<int>(21));
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      gem[y][x] = 1;
    }
    cin >> m;
    int nowx = 10;
    int nowy = 10;
    for (int j = 0; j < m; j++) {
      cin >> dim >> mer;
      for (int k = 1; k <= mer; k++) {
        if (dim == 'N')
          nowy++;
        if (dim == 'E')
          nowx++;
        if (dim == 'S')
          nowx--;
        if (dim == 'W')
          nowy--;
        gem[nowy][nowx] = 0;
      }
    }
    int boo = 0;
    for (int i = 0; i <= 20; i++) {
      for (int j = 0; j <= 20; j++) {
        if (gem[i][j])
          boo = 1;
      }
    }
    ans.push_back(boo);
    cin >> n;
  }
  for (int i = 0; i < (int)ans.size(); i++) {
    if (!ans[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>

#define MAX 32

using namespace std;

int main(void) {
  while (1) {
    int n, m;
    int x[MAX], y[MAX];
    int m_x = 10, m_y = 10;
    char d;
    int l;
    bool moved[MAX][MAX] = {false};
    moved[10][10] = true;
    bool collect = true;

    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &x[i], &y[i]);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      cin >> d >> l;
      if (d == 'N') {
        for (int j = 0; j <= l; j++) {
          moved[m_x][m_y + j] = true;
        }
        m_y += l;
      }
      if (d == 'E') {
        for (int j = 0; j <= l; j++) {
          moved[m_x + j][m_y] = true;
        }
        m_x += l;
      }
      if (d == 'S') {
        for (int j = 0; j <= l; j++) {
          moved[m_x][m_y - j] = true;
        }
        m_y -= l;
      }
      if (d == 'W') {
        for (int j = 0; j <= l; j++) {
          moved[m_x - j][m_y] = true;
        }
        m_x -= l;
      }
    }

    for (int i = 0; i < n; i++) {
      if (!moved[x[i]][y[i]])
        collect = false;
    }

    printf("%s\\n", collect ? "Yes" : "No");
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <queue>
#include <stack>

#define MAX 32

using namespace std;

int main(void) {
  while (1) {
    int n, m;
    int x[MAX], y[MAX];
    int m_x = 10, m_y = 10;
    char d;
    int l;
    bool moved[MAX][MAX] = {false};
    moved[10][10] = true;
    bool collect = true;

    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &x[i], &y[i]);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      cin >> d >> l;
      if (d == 'N') {
        for (int j = 0; j <= l; j++) {
          moved[m_x][m_y + j] = true;
        }
        m_y += l;
      }
      if (d == 'E') {
        for (int j = 0; j <= l; j++) {
          moved[m_x + j][m_y] = true;
        }
        m_x += l;
      }
      if (d == 'S') {
        for (int j = 0; j <= l; j++) {
          moved[m_x][m_y - j] = true;
        }
        m_y -= l;
      }
      if (d == 'W') {
        for (int j = 0; j <= l; j++) {
          moved[m_x - j][m_y] = true;
        }
        m_y -= l;
      }
    }

    for (int i = 0; i < n; i++) {
      if (!moved[x[i]][y[i]])
        collect = false;
    }

    printf("%s\\n", collect ? "Yes" : "No");
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int i, j, k, n, a[21][21], m;
  while (1) {
    int x = 10, y = 10;
    for (i = 0; i < 21; ++i)
      for (j = 0; j < 21; ++j)
        a[i][j] = 0;
    scanf("%d", &n);
    if (!n)
      break;
    int c, b;
    for (i = 0; i < n; ++i) {
      scanf("%d%d", &c, &b);
      a[c][b] = 1;
    }
    scanf("%d", &m);
    char d;
    int l;
    for (i = 0; i < m; ++i) {
      scanf("%c", &d);
      scanf("%c", &d);
      scanf("%d", &l);
      if (d == 'N') {
        for (j = y; j <= y + l; ++j)
          a[x][j] = 0;
        y += l;
      } else if (d == 'S') {
        for (j = y; j >= y - l; --j)
          a[x][j] = 0;
        y -= l;
      } else if (d == 'W') {
        for (j = x; j >= x - l; --j)
          a[j][y] = 0;
        x -= l;
      } else {
        for (j = x; j <= x + l; ++j)
          a[j][y] = 0;
        x += l;
      }
    }
    int ans = 0;
    for (i = 0; i < 21; ++i)
      for (j = 0; j < 21; ++j)
        ans += a[i][j];
    if (ans)
      printf("No\\n");
    else
      printf("Yes\\n");
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int i, j, k, n, a[21][21], m;
  while (1) {
    int x = 10, y = 10;
    for (i = 0; i < 21; ++i)
      for (j = 0; j < 21; ++j)
        a[i][j] = 0;
    scanf("%d", &n);
    if (!n)
      break;
    int c, b;
    for (i = 0; i < n; ++i) {
      scanf("%d%d", &c, &b);
      a[c][b] = 1;
    }
    scanf("%d", &m);
    char d;
    int l;
    for (i = 0; i < m; ++i) {
      scanf("%c", &d);
      scanf("%c", &d);
      scanf("%d", &l);
      if (d == 'N') {
        for (j = y; j <= y + l; ++j)
          a[x][j] = 0;
        y += l;
      } else if (d == 'S') {
        for (j = y; j >= y - l; --j)
          a[x][j] = 0;
        y -= l;
      } else if (d == 'W') {
        for (j = x; j >= x - l; --j)
          a[j][y] = 0;
        x += l;
      } else {
        for (j = x; j <= x + l; ++j)
          a[j][y] = 0;
        x -= l;
      }
    }
    int ans = 0;
    for (i = 0; i < 21; ++i)
      for (j = 0; j < 21; ++j)
        ans += a[i][j];
    if (ans)
      printf("No\\n");
    else
      printf("Yes\\n");
  }
  return 0;
}