#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
#define Y1 b1[0]-'a'
#define X1 b1[2]-'1'
#define Y2 b2[0]-'a'
#define X2 b2[2]-'1'
#define INF (1<<20)
using namespace std;
int dy[]={0,-1,0,1},dx[]={1,0,-1,0};
int m,n,ds,ns,nc,nj,sy,sx,gy,gx,t,
S[20][20],D[20][20][20][20]; bool V[20][20][101][4]; char b1[9],b2[9];
void dfs(int y,int x,int t,int d){
	V[y][x][t][d]=1;
	int ny,nx,nt;
	rep(nd,4){
		if((d+2)%4==nd)continue;
		ny=y+dy[nd];
		nx=x+dx[nd];
		if(!ck(ny,m)||!ck(nx,n)) continue;
		if(D[y][x][ny][nx]==INF) continue;
		nt=t+D[y][x][ny][nx];
		if(nt>100) continue;
		if(S[ny][nx]>0){
		if(nd%2==0){
			if((nt/S[ny][nx])%2!=1) continue;
			}else{
				if((nt/S[ny][nx])%2!=0) continue;
			}
		}
		if(V[ny][nx][nt][nd]) continue;
		dfs(ny,nx,nt,nd);
	}
}
int main(){
	while(cin>>m>>n,m){
		cin>>ds; rep(i,m)rep(j,n){
			S[i][j]=0; rep(k,m)rep(l,n)D[i][j][k][l]=ds;
			rep(t,101)rep(d,4)V[i][j][t][d]=0;
		}
		cin>>ns; rep(i,ns)cin>>b1>>t,S[Y1][X1]=t;
		cin>>nc; rep(i,nc)cin>>b1>>b2,D[Y1][X1][Y2][X2]=D[Y2][X2][Y1][X1]=INF;
		cin>>nj; rep(i,nj)cin>>b1>>b2>>t,D[Y1][X1][Y2][X2]+=t,D[Y2][X2][Y1][X1]+=t;
		cin>>b1>>b2,sy=Y1,sx=X1,gy=Y2,gx=X2;
		rep(d,4)dfs(sy,sx,0,d);
		rep(t,101)rep(d,4)if(V[gy][gx][t][d]){
			cout<<t<<endl; goto END;
		}
		END:;
	}
	return 0;
}