#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF LONG_MAX/2-100

template<class T>
void dijkstra(const vector<vector<pair<int,T>>> &vec, vector<T> &d, int from=0){
  using P = pair<T,int>;
  fill(all(d), INF);
  priority_queue<P, vector<P>, greater<P>> pq;
  d[from] = 0;
  pq.push(mp(0,from));
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int v = p.second;
    T dd = p.first;
    if(d[v] < dd) continue;
    for(auto to : vec[v]){
      T nd = dd + to.second;
      int ni = to.first;
      if(d[ni] > nd){
        d[ni] = nd;
        pq.push(mp(nd, ni));
      }
    }
  }
}

int main(){
  map<char,int> ma = { {'N', 0},{'E', 1},{'S',2},{'W',3} };
  int h,w,n,f;
  cin>>h>>w>>n>>f;
  int sx,sy,gx,gy;
  cin>>sx>>sy>>gx>>gy;
  sx--;sy--;gx--;gy--;
  int si = -1;
  vector<int> a(n),b(n),c(n),d(n),e(n);
  rep(i,n){
    string s;
    cin>>a[i]>>b[i]>>s>>d[i]>>e[i];
    a[i]--;
    b[i]--;
    c[i] = ma[s[0]];
    if(a[i]==sx && b[i]==sy) si = i;
  }
  if(sx==gx && sy==gy){
    cout << 0 << endl;
    return 0;
  }
  if(si==-1){
    cout << -1 << endl;
    return 0;
  }

  using P = pair<int,long>;
  vector<vector<pair<int,int>>> xx(h), yy(w); // pos, idx
  vector<vector<P>> vec(5*n+1);

  rep(i,n){
    rep(j,4){
      vec[5*i].pb(mp(5*i+j+1, (c[i]==j)?0:e[i]));
    }
    xx[a[i]].pb(mp(b[i]+d[i], 5*i+2));
    xx[a[i]].pb(mp(b[i]-d[i], 5*i+4));
    yy[b[i]].pb(mp(a[i]-d[i], 5*i+1));
    yy[b[i]].pb(mp(a[i]+d[i], 5*i+3));
  }

  xx[gx].pb(mp(gy, 5*n));
  yy[gy].pb(mp(gx, 5*n));

  rep(i,h) if(xx[i].size()){
    sort(all(xx[i]));
    rep(j,xx[i].size()-1){
      int p = xx[i][j].second, q = xx[i][j+1].second;
      long wi = (long)f*(xx[i][j+1].first - xx[i][j].first);
      vec[p].pb(mp(q, wi));
      vec[q].pb(mp(p, wi));
    }
  }

  rep(i,w) if(yy[i].size()){
    sort(all(yy[i]));
    rep(j,yy[i].size()-1){
      int p = yy[i][j].second, q = yy[i][j+1].second;
      long wi = (long)f*(yy[i][j+1].first - yy[i][j].first);
      vec[p].pb(mp(q, wi));
      vec[q].pb(mp(p, wi));
    }
  }

  rep(i,n){
    int idx = upper_bound(all(xx[a[i]]), mp(b[i], 0)) - xx[a[i]].begin();
    vec[xx[a[i]][idx].second].pb(mp(5*i, f*abs<long>(b[i] - xx[a[i]][idx].first)));
    idx--;
    vec[xx[a[i]][idx].second].pb(mp(5*i, f*abs<long>(b[i] - xx[a[i]][idx].first)));

    idx = upper_bound(all(yy[b[i]]), mp(a[i], 0)) - yy[b[i]].begin();
    vec[yy[b[i]][idx].second].pb(mp(5*i, f*abs<long>(a[i] - yy[b[i]][idx].first)));
    idx--;
    vec[yy[b[i]][idx].second].pb(mp(5*i, f*abs<long>(a[i] - yy[b[i]][idx].first)));
  }

  vector<long> dist(5*n+1);
// rep(i,11)dbg(i,vec[i]);
  dijkstra(vec, dist, si*5);
// dbg(dist);
  if(dist[5*n]==INF) cout << -1 << endl;
  else cout << dist[5*n] << endl;

  return 0;
}


Measured memory_bytes: 48116