#include <bits/stdc++.h>
using namespace std;
namespace MF {
int n, m, s, t, to[(1000 * 1000)];
long long fl[(1000 * 1000)], cp[(1000 * 1000)];
int dst[1000];
vector<int> al[1000];
queue<int> q;
void init(int _n) {
  n = _n + 2;
  m = 0;
  s = _n;
  t = _n + 1;
  for (int i = (0); i < (n); i++) al[i].clear();
}
void add(int a, int b, long long c) {
  al[a].push_back(m);
  to[m] = b;
  fl[m] = 0;
  cp[m] = c;
  m++;
  al[b].push_back(m);
  to[m] = a;
  fl[m] = 0;
  cp[m] = 0;
  m++;
}
bool bfs() {
  for (int i = (0); i < (n); i++) dst[i] = i == s ? 0 : -1;
  q.push(s);
  while (!q.empty()) {
    int at = q.front();
    q.pop();
    for (int i = (0); i < (al[at].size()); i++) {
      int e = al[at][i];
      if (dst[to[e]] != -1 || fl[e] == cp[e]) continue;
      dst[to[e]] = dst[at] + 1;
      q.push(to[e]);
    }
  }
  return dst[t] != -1;
}
long long aug(int at, long long cf) {
  if (at == t) return cf;
  for (int i = (0); i < (al[at].size()); i++) {
    int e = al[at][i];
    if (dst[to[e]] != dst[at] + 1 || fl[e] == cp[e]) continue;
    long long tf = aug(to[e], min(cf, cp[e] - fl[e]));
    if (tf) {
      fl[e] += tf;
      fl[e ^ 1] -= tf;
      return tf;
    }
  }
  dst[at] = -1;
  return 0;
}
long long mf() {
  long long ans = 0;
  while (bfs())
    for (int add = aug(s, 1e18); add; add = aug(s, 1e18)) ans += add;
  return ans;
}
}  // namespace MF
int n, m, ml, fml, id[12][12], y[200], x[200], iut, my[200], mx[200], fy[200],
    fx[200], by, bx;
long long mt[200], ft[200], dst[200][200], bt;
int dy[] = {1, 0, 0, -1};
int dx[] = {0, 1, -1, 0};
long long mi = 0, ma = 1000000000000LL, mid;
char gr[12][12];
int main() {
  scanf("%d %d %d %d", &n, &m, &ml, &fml);
  if (abs(ml - fml) != 1) {
    puts("-1");
    return 0;
  }
  for (int i = (0); i < (n); i++) {
    scanf("%s", gr[i]);
    for (int j = (0); j < (m); j++)
      if (gr[i][j] == '.') {
        id[i][j] = iut;
        y[iut] = i;
        x[iut] = j;
        iut++;
      }
  }
  scanf("%d %d %lld", &by, &bx, &bt);
  by--;
  bx--;
  for (int i = (0); i < (ml); i++)
    scanf("%d %d %lld", my + i, mx + i, mt + i), my[i]--, mx[i]--;
  for (int i = (0); i < (fml); i++)
    scanf("%d %d %lld", fy + i, fx + i, ft + i), fy[i]--, fx[i]--;
  if (ml > fml) {
    fy[fml] = by;
    fx[fml] = bx;
    ft[fml] = bt;
    fml++;
  } else {
    my[ml] = by;
    mx[ml] = bx;
    mt[ml] = bt;
    ml++;
  }
  for (int i = (0); i < (iut); i++)
    for (int j = (i + 1); j < (iut); j++)
      dst[i][j] = dst[j][i] = 1000000000000LL;
  for (int i = (0); i < (iut); i++)
    for (int d = (0); d < (4); d++) {
      int ny = y[i] + dy[d], nx = x[i] + dx[d];
      if (ny < 0 || ny >= n || nx < 0 || nx >= m || gr[ny][nx] == '#') continue;
      dst[i][id[ny][nx]] = 1;
    }
  for (int i = (0); i < (iut); i++)
    for (int j = (0); j < (iut); j++)
      for (int k = (0); k < (iut); k++)
        dst[j][k] = min(dst[j][k], dst[j][i] + dst[i][k]);
  while (mi != ma) {
    mid = (mi + ma) / 2;
    MF::init(ml + 2 * (iut + fml));
    for (int i = (0); i < (ml); i++) MF::add(MF::s, i, 1);
    for (int i = (0); i < (iut); i++) MF::add(ml + 2 * i, ml + 2 * i + 1, 1);
    for (int i = (0); i < (fml); i++)
      MF::add(ml + 2 * iut + 2 * i, ml + 2 * iut + 2 * i + 1, 1),
          MF::add(ml + 2 * iut + 2 * i + 1, MF::t, 1);
    for (int i = (0); i < (ml); i++)
      for (int j = (0); j < (iut); j++)
        if (dst[j][id[my[i]][mx[i]]] < 1000000000000LL &&
            mt[i] * dst[j][id[my[i]][mx[i]]] <= mid)
          MF::add(i, ml + 2 * j, 1);
    for (int i = (0); i < (fml); i++)
      for (int j = (0); j < (iut); j++)
        if (dst[j][id[fy[i]][fx[i]]] < 1000000000000LL &&
            ft[i] * dst[j][id[fy[i]][fx[i]]] <= mid)
          MF::add(ml + 2 * j + 1, ml + 2 * iut + 2 * i, 1);
    if (MF::mf() == ml)
      ma = mid;
    else
      mi = mid + 1;
  }
  printf("%lld\n", mi == 1000000000000LL ? -1 : mi);
  return 0;
}
