#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
void parse(int& x, int& y) {
    string s;
    cin >> s;
    y = s[0] - 'a';
    x = stoi(s.substr(2));
    x--;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef tuple<int, int, int, int> T; // dist, x, y, r

bool valid(int x, int w) {
    return 0 <= x && x < w;
}

int main(){
    int H, W;
    while(cin >> H >> W && H > 0) {
        int D;
        cin >> D;
        int ns;
        cin >> ns;

        int K[21][21] = {};
        REP(i, ns) {
            int x, y;
            parse(x, y);
            cin >> K[y][x];
        }

        int nc;
        cin >> nc;
        bool forbid[21][21][4] = {};
        REP(i, nc) {
            int x1, y1, x2, y2;
            parse(x1, y1);
            parse(x2, y2);
            if(x1 == x2) {
                if(y1 > y2) swap(y1, y2);
                forbid[y1][x1][1] = true;
                forbid[y2][x1][3] = true;
            } else {
                if(x1 > x2) swap(x1, x2);
                forbid[y1][x1][0] = true;
                forbid[y1][x2][2] = true;
            }
        }

        int cost[21][21][4] = {};
        int nj;
        cin >> nj;
        REP(i, nj) {
            int x1, y1, x2, y2;
            parse(x1, y1);
            parse(x2, y2);
            int d;
            cin >> d;
            if(x1 == x2) {
                if(y1 > y2) swap(y1, y2);
                cost[y1][x1][1] = d;
                cost[y2][x1][3] = d;
            } else {
                if(x1 > x2) swap(x1, x2);
                cost[y1][x1][0] = d;
                cost[y1][x2][2] = d;
            }
        }

        int sx, sy, gx, gy;
        parse(sx, sy);
        parse(gx, gy);

        priority_queue<T, vector<T>, greater<T>> que;
        bool memo[20][20][4][101] = {};
        REP(r, 4) {
            memo[sy][sx][r][0] = true;
            que.push(T(0, sx, sy, r));
        }

        int ans = INT_MAX;
        while(!que.empty()) {
            T _t = que.top(); que.pop();
            int d, x, y, pr;
            tie(d, x, y, pr) = _t;
            //printf("d = %d x = %d y = %d pr = %d\n", d, x, y, pr);

            if(K[y][x] != 0) {
                int t = (d / K[y][x]);
                if((pr + 1) % 2 != t % 2) continue;
            }

            if(x == gx && y == gy) {
                ans = d;
                break;
            }

            REP(r, 4) if((r + 2) % 4 != pr) {
                int nx = x + dx[r];
                int ny = y + dy[r];
                if(!valid(nx, W)) continue;
                if(!valid(ny, H)) continue;
                if(forbid[y][x][r]) continue;

                // ??
                //if(K[y][x] != 0 && (d / K[y][x]) % 2 != (r + 1) % 2) continue;

                int nd = d + D + cost[y][x][r];
                if(nd > 100) continue;
                if(memo[ny][nx][r][nd]) continue;

                memo[ny][nx][r][nd] = true;
                que.push(T(nd, nx, ny, r));
            }
        }

        assert(ans != INT_MAX);
        cout << ans << endl;
    }
    return 0;
}