#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {-1, 1, 0, 0};
char grid[33][33];
int N, M, nf, nm;
int E, V, src, tar, head[11111], dis[11111], work[11111], to[1111111],
    nxt[1111111], cap[1111111];
int qf, qb, q[1111111];
int dst[33][33][33][33];
int fu[11111], fv[11111], mu[11111], mv[11111], ft[11111], mt[11111];
void init(int n, int s, int t) {
  memset(head, -1, sizeof(int) * n);
  V = n;
  E = 0;
  src = s;
  tar = t;
}
void add_edge(int u, int v, int c) {
  to[E] = v;
  cap[E] = c;
  nxt[E] = head[u];
  head[u] = E++;
  to[E] = u;
  cap[E] = 0;
  nxt[E] = head[v];
  head[v] = E++;
}
bool bfs() {
  memset(dis, -1, sizeof(dis));
  qf = qb = 0;
  q[qb++] = src;
  dis[src] = 0;
  while (qf < qb && dis[tar] == -1) {
    int u = q[qf++];
    for (int i = head[u]; i >= 0; i = nxt[i]) {
      int v = to[i];
      if (dis[v] == -1 && cap[i] > 0) {
        dis[v] = dis[u] + 1;
        q[qb++] = v;
      }
    }
  }
  return dis[tar] >= 0;
}
int dfs(int u, int &bot) {
  int v, bot1, delta;
  if (u == tar) return bot;
  for (int &i = work[u]; i >= 0; i = nxt[i]) {
    v = to[i];
    if (dis[v] != dis[u] + 1 || cap[i] == 0) continue;
    bot1 = min(bot, cap[i]);
    if (delta = dfs(v, bot1)) {
      cap[i] -= delta;
      cap[i ^ 1] += delta;
      bot = bot1;
      return delta;
    }
  }
  return 0;
}
int dinic() {
  int ans = 0, delta, bot;
  while (bfs()) {
    memcpy(work, head, sizeof(int) * V);
    delta = 0x3f3f3f3f;
    while (delta = dfs(src, bot = 0x3f3f3f3f)) ans += delta;
  }
  return ans;
}
int can(long long mid) {
  src = 2 * nf + 2 * N * M;
  tar = src + 1;
  init(tar + 1, src, tar);
  int i, u, v, ii, jj;
  for (i = 0; i < nf; i++) {
    u = fu[i];
    v = fv[i];
    add_edge(src, i, 1);
    for (ii = 0; ii < N; ii++)
      for (jj = 0; jj < M; jj++) {
        if (dst[u][v][ii][jj] > 0x3f3f3f3f - 10) continue;
        if (mid >= (long long)ft[i] * dst[u][v][ii][jj]) {
          add_edge(i, nf + ii * M + jj, 1);
        }
      }
  }
  for (i = 0; i < nm; i++) {
    u = mu[i];
    v = mv[i];
    add_edge(i + nf + 2 * N * M, tar, 1);
    for (ii = 0; ii < N; ii++)
      for (jj = 0; jj < M; jj++) {
        if (dst[u][v][ii][jj] > 0x3f3f3f3f - 10) continue;
        if (mid >= (long long)mt[i] * dst[u][v][ii][jj]) {
          add_edge(nf + ii * M + jj + N * M, i + nf + 2 * N * M, 1);
        }
      }
  }
  for (i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      add_edge(i * M + j + nf, i * M + j + nf + N * M, 1);
    }
  if (dinic() == nf) return 1;
  return 0;
}
int main() {
  int i, j, u, v, bu, bv, bt, k;
  int uu, vv;
  long long st, ed, mid;
  scanf("%d%d%d%d", &N, &M, &nm, &nf);
  for (i = 0; i < N; i++) scanf("%s", grid[i]);
  scanf("%d%d%d", &bu, &bv, &bt);
  bu--;
  bv--;
  for (i = 0; i < nm; i++) {
    scanf("%d%d%d", &mu[i], &mv[i], &mt[i]);
    mu[i]--;
    mv[i]--;
  }
  for (i = 0; i < nf; i++) {
    scanf("%d%d%d", &fu[i], &fv[i], &ft[i]);
    fu[i]--;
    fv[i]--;
  }
  if (abs(nm - nf) != 1) {
    puts("-1");
    return 0;
  }
  if (nm < nf) {
    mu[nm] = bu;
    mv[nm] = bv;
    mt[nm] = bt;
    nm++;
  } else {
    fu[nf] = bu;
    fv[nf] = bv;
    ft[nf] = bt;
    nf++;
  }
  memset(dst, 0x3f, sizeof(dst));
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) {
      if (grid[i][j] == '#') continue;
      dst[i][j][i][j] = 0;
      qf = qb = 0;
      q[qb++] = i;
      q[qb++] = j;
      while (qf < qb) {
        u = q[qf++];
        v = q[qf++];
        for (k = 0; k < 4; k++) {
          uu = u + dx[k];
          vv = v + dy[k];
          if ((uu < 0 || vv < 0 || uu >= N || vv >= M)) continue;
          if (grid[uu][vv] == '#') continue;
          if (dst[i][j][uu][vv] > dst[i][j][u][v] + 1) {
            dst[i][j][uu][vv] = dst[i][j][u][v] + 1;
            q[qb++] = uu;
            q[qb++] = vv;
          }
        }
      }
    }
  st = 0;
  ed = 0x3f3f3f3f3f3f3f3fLL;
  while (ed - st > 1) {
    mid = (st + ed) / 2;
    if (can(mid))
      ed = mid;
    else
      st = mid;
  }
  if (ed > 0x3f3f3f3f3f3f3f3fLL - 10) {
    puts("-1");
    return 0;
  }
  if (can(st))
    printf("%I64d\n", st);
  else
    printf("%I64d\n", ed);
  return 0;
}
