#include <iostream>
#include <string.h>
using namespace std;

int x,y,ex,ey,m,n,mi;
int vx[4]={1,0,-1,0},vy[4]={0,-1,0,1};
int s[20][20][101];
int t[20][20][4];

void getxy(char *a) {
	y=a[0]-'a';
	if (strlen(a)==3) x=a[2]-'0'; else { x=(a[2]-'0')*10+a[3]-'0';}
	x--;
	}
void search(int v,int x,int y,int ta) {
	int i; 
	s[y][x][ta] |= (1 << v);
	if (x==ex && y==ey) { if (ta<mi) mi=ta; return;}
	for (i=0;i<4;i++) {
	 if (x+vx[i]>n-1 || x+vx[i]<0 || y+vy[i]>m-1 || y+vy[i]<0 || ta+t[y][x][i]>100 ) continue;
	 if ((s[y+vy[i]][x+vx[i]][ta+t[y][x][i]] & (1 << i))!=0 || (i-v)*(i-v)==4) continue;
	 search(i,x+vx[i],y+vy[i],ta+t[y][x][i]);
 }
}  	
	
int main()
{
	char ch[5];
	int d,i,j,k,g,e,x1,y1,v;
	while(cin >> m >> n) {
		if (m+n==0) break;
	    cin >> v; mi=100;
	    for (i=0;i<20;i++) for (j=0;j<20;j++)
	        { for (k=0;k<4;k++) t[i][j][k]=v; for (k=0;k<101;k++) s[i][j][k]=0; }
	    cin >> d;
	    for (i=0; i<d; i++) {
	      cin >> ch; getxy(ch); cin >> g; e=10;
	        for (j=0;j<101;j++) {
			if ((j % g)==0) {if (e==10) e=5; else e=10;}
			s[y][x][j]=e; }
		}
        cin >> d;
        for (i=0 ;i<d; i++) {
			cin >> ch; getxy(ch); x1=x; y1=y; cin >> ch; getxy(ch); 
			for (j=0;j<101;j++) {
				s[y1][x1][j]|=((x1<x)*4+(x1>x)+(y1<y)*2+(y1>y)*8);
				  s[y][x][j]|=((x<x1)*4+(x>x1)+(y<y1)*2+(y>y1)*8);
				}
		}
		cin >> d;
		for (i=0; i<d; i++) {
			cin >> ch; getxy(ch); x1=x; y1=y; cin >> ch; getxy(ch); cin >> g;
			    t[y1][x1][(x1>x)*2+(y1<y)*3+(y1>y)]=t[y][x][(x>x1)*2+(y<y1)*3+(y>y1)]=v+g;
				}
		cin >> ch; getxy(ch); x1=x;y1=y; cin >> ch; getxy(ch); ex=x;ey=y;
		search(0,x1,y1,0);
		cout << mi << endl;		
		}
	return 0;
}