#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint f;
	int i,j,H,W,n,sx,sy,gx,gy,sta=-1;cin>>H>>W>>n>>f>>sx>>sy>>gx>>gy;
	vector<vector<pair<int,int>>>tate(H+1);
	vector<vector<pair<int,int>>>yoko(W+1);
	vector<vector<pair<llint,int>>>go(n*7+2);
	for(i=0;i<n;i++){
		int a,b,d;char c;llint e;
		cin>>a>>b>>c>>d>>e;
		//cerr<<a<<b<<c<<d<<e;
		if(sx==a&&sy==b){sta=i;}
		tate[a].pub(mp(b,i+n));
		go[i+n].pub(mp(0LL,i));
		yoko[b].pub(mp(a,i+n*2));
		go[i+n*2].pub(mp(0LL,i));
		tate[a].pub(mp(b-d,i+n*3));
		go[i].pub(mp((c=='W'?0:e),i+n*3));
		tate[a].pub(mp(b+d,i+n*4));
		go[i].pub(mp((c=='E'?0:e),i+n*4));
		yoko[b].pub(mp(a-d,i+n*5));
		go[i].pub(mp((c=='N'?0:e),i+n*5));
		yoko[b].pub(mp(a+d,i+n*6));
		go[i].pub(mp((c=='S'?0:e),i+n*6));
	}
	if(sta==-1){cout<<-1<<endl;return 0;}
	tate[gx].pub(mp(gy,n*7));
	yoko[gy].pub(mp(gx,n*7+1));
	for(i=1;i<=H;i++){
		if(tate[i].size()==0){continue;}
		SO(tate[i]);
		int mae=tate[i][0].sec;
		for(j=1;j<tate[i].size();j++){
			int it=tate[i][j].sec;
			llint cost=(tate[i][j].fir-tate[i][j-1].fir)*f;
			go[mae].pub(mp(cost,it));
			go[it].pub(mp(cost,mae));
			mae=it;
		}
	}
	for(i=1;i<=W;i++){
		if(yoko[i].size()==0){continue;}
		SO(yoko[i]);
		int mae=yoko[i][0].sec;
		for(j=1;j<yoko[i].size();j++){
			int it=yoko[i][j].sec;
			llint cost=(yoko[i][j].fir-yoko[i][j-1].fir)*f;
			go[mae].pub(mp(cost,it));
			go[it].pub(mp(cost,mae));
			mae=it;
		}
	}
	//単純ダイクストラ法
	priority_queue<pair<llint,int>,vector<pair<llint,int>>,greater<pair<llint,int>>> que;
	que.push(mp(0LL,sta));
	vector<llint>dis(7*n+2,big);
	dis[sta]=0;
	while(que.size()){
		int ter;
		llint time;
		tie(time,ter)=que.top();
		if(ter>=7*n){cout<<time<<endl;return 0;}
		que.pop();
		if(dis[ter]<time){continue;}
		for(auto it:go[ter]){
			if(mineq(dis[it.sec],time+it.fir)){que.push(mp(time+it.fir,it.sec));}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 60144