#include<iostream>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

typedef pair<int,int> P1;
typedef pair<P1,P1> P2;

int stoi(string x){return atoi(x.substr(2,(int)x.size()-2).c_str());}

int main(){
  int i,k;
  int mint[20][20][4];
  bool crash[20][20][20][20];
  int sig[20][20],cost[20][20][20][20];
  int m,n,d,ns,nc,nj,sw,sh,gw,gh;
  string str;

  for(;;){
    cin >> m >> n;
    if(!m && !n)break;

    cin >> d;
    fill(&cost[0][0][0][0],&cost[m-1][n-1][m-1][n-1]+1,d);

    cin >> ns;    
    fill(&sig[0][0],&sig[m-1][m-1]+1,0);
    for(i=0;i<ns;i++){
      cin >> str >> k;
      sh = str[0]-'a';
      sw = stoi(str)-1;
      sig[sh][sw] = k;
    }

    cin >> nc;
    fill(&crash[0][0][0][0],&crash[m-1][n-1][m-1][n-1]+1,false); 
    for(i=0;i<nc;i++){
      cin >> str;
      sh = str[0]-'a';
      sw = stoi(str)-1;
      cin >> str;
      gh = str[0]-'a';
      gw = stoi(str)-1;
      crash[sh][sw][gh][gw] = true;
      crash[gh][gw][sh][sw] = true;
    }

    cin >> nj;
    for(i=0;i<nj;i++){
      cin >> str;
      sh = str[0]-'a';
      sw = stoi(str)-1;
      cin >> str;
      gh = str[0]-'a';
      gw = stoi(str)-1;
      cin >> k;
      cost[sh][sw][gh][gw] += k;
      cost[gh][gw][sh][sw] += k;
    }

    cin >> str;
    sh = str[0]-'a';
    sw = stoi(str)-1;
    cin >> str;
    gh = str[0]-'a';
    gw = stoi(str)-1;

    fill(&mint[0][0][0],&mint[m-1][n-1][4]+1,1<<30);
    mint[sh][sw][0] = 0;
    queue<P2> q;
    q.push(P2(P1(0,0),P1(sh,sw)));

    while(q.size()){
      P2 p=q.front();q.pop();
      int t = p.first.first;
      int d = p.first.second;
      int y = p.second.first;
      int x = p.second.second;

      for(i=-1;i<=1;i++){
	int dd = ((d+i)%4+4)%4;
	int dy=y,dx=x,dt=t;
	if(dd==0)dx++;
	if(dd==1)dy++;
	if(dd==2)dx--;
	if(dd==3)dy--;
	if(dy<0 || dx<0 || m<=dy || n<=dx)continue;
	if(crash[y][x][dy][dx])continue;
	dt += cost[y][x][dy][dx];
	k = sig[dy][dx];
	if(k){
	  if(dt%(2*k) < k){
	    if(!(dd&1))continue;
	  }else{
	    if(dd&1)continue;
	  }
	}
	if(mint[dy][dx][dd] > dt){
	  mint[dy][dx][dd] = dt;
	  q.push(P2(P1(dt,dd),P1(dy,dx)));
	}
      }
    }
    /*
    for(i=0;i<4;i++){
      for(j=0;j<m;j++){
	for(k=0;k<n;k++)cout << mint[j][k][i] << " ";
	cout << endl;
      }
      cout << endl;
    }
    */
    int ans = 1<<30;
    for(i=0;i<4;i++)ans = min(ans,mint[gh][gw][i]);
    cout << ans << endl;
  }
}