#include<iostream>
#include<string>
#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[]={-1,0,1,0},dx[]={0,1,0,-1};
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]; string b1,b2;
void dfs(int y,int x,int t,int d){
	V[y][x][t][d]=1;
	int ny,nx,c,nt,nd;
	rep(i,4){
		nd=d+i&3,ny=y+dy[nd],nx=x+dx[nd];
		if(ck(ny,m)&&ck(nx,n)&&i!=2){
			c=D[y][x][ny][nx],nt=t+c;
			if((!S[ny][nx]||nd%2==nt/S[ny][nx]%2)&&c!=INF
			&&nt<101&&!V[ny][nx][nt][nd])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;
}