#include <bits/stdc++.h>

using namespace std;

int n,k;

int sssp(int s, int g,vector<vector<int> > ship){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
  vector<bool> used(n+1,false);

  q.push(make_pair(0,s));
  while(!q.empty()){
    int cost=q.top().first,now=q.top().second; q.pop();
    used[now]=true;
    if(now==g) return cost;

    for(int i=1;i<=n;++i){
      if(ship[now][i]==1000005) continue;
      int ncost=cost+ship[now][i],nexto=i;
      if(used[nexto]==false) q.push(make_pair(ncost,nexto));
    }
  }
  return -1;
}

int main(){
  while(cin >> n >>k && (n || k)){
    vector<vector<int> > ship(n+1,vector<int>(n+1,1000005));
    while(k--){
      int info; cin >> info;
      if(info==0){
	int a,b; cin >> a >> b;
	cout << sssp(a,b,ship) << endl;
      }else{
	int c,d,e; cin >> c >> d >> e;
	ship[c][d]=ship[d][c]=min(ship[c][d],e);
      }
    }
  }
  
  return 0;
}


#include <algorithm>
#include <iostream>
#include <limits.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed

using namespace std;

class Point
{
private:
  int m_x;
  int m_y;
public:
  void setX(int x);
  void setY(int y);
  int getX();
  int getY();

  Point(int x, int y) {
    setX(x);
    setY(y);
  }
};

void Point::setX(int x) {
  m_x = x;
}

void Point::setY(int y) {
  m_y = y;
}

int Point::getX() {
  return m_x;
}

int Point::getY() {
  return m_y;
}

int main() {
  int N, x, y, M, l, rx, ry;
  string d;
  while (1) {
    cin >> N;
    vector<Point> gems;
    if (N == 0) break;
    for (int i = 0; i < N; i++) {
      cin >> x >> y;
      gems.push_back(Point(x, y));
    }
    cin >> M;
    rx = 10;
    ry = 10;
    while (M--) {
      cin >> d >> l;
      while (l--) {
        if (d == "N") ry++;
        if (d == "E") rx++;
        if (d == "S") ry--;
        if (d == "W") rx--;
        for (int i = 0; i < gems.size(); i++) {
          if (rx == gems[i].getX() && ry == gems[i].getY()) {
            gems.erase(gems.begin()+i);
            break;
          }
        }
      }
    }
    if (gems.empty()) cout << "Yes" << el;
    else cout << "No" << el;
  }
}