#include <bits/stdc++.h>
using namespace std;
const int N = 25 * 25 * 25 * 25;
struct bian {
  int from, to;
  long long w;
} eg[N << 4];
int front[N], num, s, t;
void add(int x, int y, long long w) {
  eg[++num].to = y;
  eg[num].from = front[x];
  front[x] = num;
  eg[num].w = w;
  swap(x, y);
  eg[++num].to = y;
  eg[num].from = front[x];
  front[x] = num;
  eg[num].w = 0;
}
int _front[N], _dis[N];
bool bfs() {
  queue<int> q;
  q.push(s);
  memset(_dis, 0, sizeof(_dis));
  _dis[s] = 1;
  while (!q.empty()) {
    int o = q.front();
    q.pop();
    for (int i = front[o]; i; i = eg[i].from) {
      int to = eg[i].to;
      if (eg[i].w && _dis[to] == 0) {
        _dis[to] = _dis[o] + 1;
        q.push(to);
      }
    }
  }
  return _dis[t] != 0;
}
long long dfs(int o, long long lim) {
  if (o == t) return lim;
  int mins = 0;
  for (int &i = _front[o]; i; i = eg[i].from) {
    int to = eg[i].to;
    if (_dis[to] != _dis[o] + 1 || eg[i].w == 0) continue;
    long long now = dfs(to, min(lim - mins, eg[i].w));
    if (now) {
      eg[i].w -= now;
      eg[((i - 1) ^ 1) + 1].w += now;
      mins += now;
      if (mins == lim) break;
    }
  }
  return mins;
}
long long dinic() {
  int re = 0;
  while (bfs()) {
    memcpy(_front, front, sizeof(_front));
    re += dfs(s, 1e18);
  }
  return re;
}
int n, m, males, females;
long long dis[25][25][25][25];
char S[25][25];
int calc(int x, int y) { return (x - 1) * m + y; }
long long x, y, v, mx[10010], my[10010], mw[10010], fx[10010], fy[10010],
    fw[10010];
bool check(long long w) {
  num = 0;
  memset(front, 0, sizeof(front));
  s = 2 * n * m + males * 2 + 1;
  t = s + 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) add(calc(i, j), calc(i, j) + n * m, 1);
  }
  for (int i = 1; i <= males; ++i) {
    add(s, 2 * n * m + i, 1);
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= m; ++k)
        if (S[j][k] == '.' && dis[j][k][mx[i]][my[i]] != 1e9 &&
            dis[j][k][mx[i]][my[i]] * mw[i] <= w)
          add(2 * n * m + i, calc(j, k), 1);
    }
  }
  for (int i = 1; i <= females; ++i) {
    add(2 * n * m + males + i, t, 1);
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= m; ++k)
        if (S[j][k] == '.' && dis[j][k][fx[i]][fy[i]] != 1e9 &&
            dis[j][k][fx[i]][fy[i]] * fw[i] <= w)
          add(calc(j, k) + n * m, 2 * n * m + males + i, 1);
    }
  }
  return (dinic() == males);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &males, &females);
  if (abs(males - females) != 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%s", S[i] + 1);
  }
  for (int i = 0; i < 25; ++i) {
    for (int j = 0; j < 25; ++j) {
      for (int k = 0; k < 25; ++k) {
        for (int l = 0; l < 25; ++l) dis[i][j][k][l] = 1e9;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (S[i][j] == '.') {
        dis[i][j][i][j] = 0;
        if (S[i + 1][j] == '.') dis[i][j][i + 1][j] = 1;
        if (S[i - 1][j] == '.') dis[i][j][i - 1][j] = 1;
        if (S[i][j + 1] == '.') dis[i][j][i][j + 1] = 1;
        if (S[i][j - 1] == '.') dis[i][j][i][j - 1] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int k = 1; k <= n; ++k) {
        for (int l = 1; l <= m; ++l) {
          for (int o = 1; o <= n; ++o) {
            for (int p = 1; p <= m; ++p) {
              dis[k][l][o][p] =
                  min(dis[k][l][i][j] + dis[i][j][o][p], dis[k][l][o][p]);
            }
          }
        }
      }
    }
  }
  scanf("%lld%lld%lld", &x, &y, &v);
  for (int i = 1; i <= males; ++i)
    scanf("%lld%lld%lld", &mx[i], &my[i], &mw[i]);
  if (males < females) ++males, mx[males] = x, my[males] = y, mw[males] = v;
  for (int i = 1; i <= females; ++i)
    scanf("%lld%lld%lld", &fx[i], &fy[i], &fw[i]);
  if (males > females)
    ++females, fx[females] = x, fy[females] = y, fw[females] = v;
  long long l = 0, r = 1e14, ans = -1;
  for (long long mid = (l + r) >> 1; l <= r; mid = (l + r) >> 1) {
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans == 1e14 ? -1 : ans);
}
