#include<cstdio>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
int m,n,ds,ns,nc,nj,sy,sx,gy,gx,t,x1,x2,
S[20][20],D[20][20][20][20]; bool V[20][20][101][4];
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,c)&&(!S[ny][nx]||
		nd%2==nt/S[ny][nx]%2)&&nt<101&&!V[ny][nx][nt][nd])dfs(ny,nx,nt,nd);
	}
}
int main(){
	END:while(scanf("%d%d",&m,&n),m){
		scanf("%d",&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;
		}
		char y1,y2;
		scanf("%d",&ns); rep(i,ns)scanf(" %c-%d %d",&y1,&x1,&t),S[y1-'a'][x1-1]=t;
		scanf("%d",&nc); rep(i,nc)scanf(" %c-%d %c-%d",&y1,&x1,&y2,&x2),
		D[y1-'a'][x1-1][y2-'a'][x2-1]=D[y2-'a'][x2-1][y1-'a'][x1-1]=0;
		scanf("%d",&nj); rep(i,nj)scanf(" %c-%d %c-%d %d",&y1,&x1,&y2,&x2,&t),
		D[y1-'a'][x1-1][y2-'a'][x2-1]+=t,D[y2-'a'][x2-1][y1-'a'][x1-1]+=t;
		scanf(" %c-%d %c-%d",&y1,&x1,&y2,&x2),sy=y1-'a',sx=x1-1,gy=y2-'a',gx=x2-1;
		rep(d,4)dfs(sy,sx,0,d);
		rep(t,101)rep(d,4)if(V[gy][gx][t][d]){
			printf("%d\n",t); goto END;
		}
	}
	return 0;
}