#include <bits/stdc++.h>
using namespace std;
int cap[1000000], flow[1000000];
int to[1000000], _prev[1000000], last[10000], used[10000], level[10000];
struct MaxFlow {
  int V, E;
  MaxFlow(int n) {
    int i;
    V = n;
    E = 0;
    for ((i) = 0; (i) < (int)(V); (i)++) last[i] = -1;
  }
  void add_edge(int x, int y, int f) {
    cap[E] = f;
    flow[E] = 0;
    to[E] = y;
    _prev[E] = last[x];
    last[x] = E;
    E++;
    cap[E] = 0;
    flow[E] = 0;
    to[E] = x;
    _prev[E] = last[y];
    last[y] = E;
    E++;
  }
  bool bfs(int s, int t) {
    int i;
    for ((i) = 0; (i) < (int)(V); (i)++) level[i] = -1;
    queue<int> q;
    q.push(s);
    level[s] = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (i = last[x]; i >= 0; i = _prev[i])
        if (level[to[i]] == -1 && cap[i] > flow[i]) {
          q.push(to[i]);
          level[to[i]] = level[x] + 1;
        }
    }
    return (level[t] != -1);
  }
  int dfs(int v, int t, int f) {
    int i;
    if (v == t) return f;
    for (i = used[v]; i >= 0; used[v] = i = _prev[i])
      if (level[to[i]] > level[v] && cap[i] > flow[i]) {
        int tmp = dfs(to[i], t, min(f, cap[i] - flow[i]));
        if (tmp > 0) {
          flow[i] += tmp;
          flow[i ^ 1] -= tmp;
          return tmp;
        }
      }
    return 0;
  }
  int maxflow(int s, int t) {
    int i;
    while (bfs(s, t)) {
      for ((i) = 0; (i) < (int)(V); (i)++) used[i] = last[i];
      while (dfs(s, t, (1 << 29)) != 0)
        ;
    }
    int ans = 0;
    for (i = last[s]; i >= 0; i = _prev[i]) ans += flow[i];
    return ans;
  }
};
const int MAXSIZE = 25;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int n, m, male, female;
char graph[MAXSIZE][MAXSIZE];
int br, bc, bt;
int mr[MAXSIZE * MAXSIZE], mc[MAXSIZE * MAXSIZE], mt[MAXSIZE * MAXSIZE];
int fr[MAXSIZE * MAXSIZE], fc[MAXSIZE * MAXSIZE], ft[MAXSIZE * MAXSIZE];
int dis[MAXSIZE][MAXSIZE][MAXSIZE][MAXSIZE];
queue<int> Q;
void bfs(int x, int y) {
  int i;
  if (graph[x][y] == '#') {
    return;
  }
  dis[x][y][x][y] = 0;
  Q.push(x), Q.push(y);
  while (!Q.empty()) {
    int nx = Q.front();
    Q.pop();
    int ny = Q.front();
    Q.pop();
    for ((i) = 0; (i) < (int)(4); (i)++) {
      int tx = nx + dx[i];
      int ty = ny + dy[i];
      if (0 <= tx && tx < n && 0 <= ty && ty < m && dis[x][y][tx][ty] < 0 &&
          graph[tx][ty] == '.') {
        dis[x][y][tx][ty] = dis[x][y][nx][ny] + 1;
        Q.push(tx), Q.push(ty);
      }
    }
  }
}
bool check(long long val) {
  int i, j, k;
  MaxFlow mf(2 * male + 2 * n * m + 2);
  int V = 2 * male + 2 * n * m + 2;
  for ((i) = 0; (i) < (int)(male); (i)++) mf.add_edge(V - 2, i, 1);
  for ((i) = 0; (i) < (int)(n * m); (i)++)
    mf.add_edge(male + i, male + n * m + i, 1);
  for ((i) = 0; (i) < (int)(male); (i)++)
    mf.add_edge(male + 2 * n * m + i, V - 1, 1);
  for ((i) = 0; (i) < (int)(n); (i)++) {
    for ((j) = 0; (j) < (int)(m); (j)++) {
      if (graph[i][j] == '#') continue;
      for ((k) = 0; (k) < (int)(male); (k)++) {
        int d1 = dis[mr[k]][mc[k]][i][j];
        if (d1 >= 0 && 1ll * mt[k] * d1 <= val) {
          mf.add_edge(k, male + i * m + j, 1);
        }
        int d2 = dis[fr[k]][fc[k]][i][j];
        if (d2 >= 0 && 1ll * ft[k] * d2 <= val) {
          mf.add_edge(male + n * m + i * m + j, male + 2 * n * m + k, 1);
        }
      }
    }
  }
  int flow = mf.maxflow(V - 2, V - 1);
  return (flow == male);
}
int MAIN() {
  int i, j;
  scanf("%d%d%d%d", &n, &m, &male, &female);
  for ((i) = 0; (i) < (int)(n); (i)++) scanf("%s", graph[i]);
  scanf("%d%d%d", &br, &bc, &bt);
  br--, bc--;
  for ((i) = 0; (i) < (int)(male); (i)++)
    scanf("%d%d%d", &mr[i], &mc[i], &mt[i]);
  for ((i) = 0; (i) < (int)(female); (i)++)
    scanf("%d%d%d", &fr[i], &fc[i], &ft[i]);
  for ((i) = 0; (i) < (int)(male); (i)++) {
    mr[i]--, mc[i]--;
  }
  for ((i) = 0; (i) < (int)(female); (i)++) {
    fr[i]--, fc[i]--;
  }
  if (abs(male - female) != 1) {
    printf("-1\n");
    return 0;
  }
  if (male < female) {
    mr[male] = br, mc[male] = bc, mt[male++] = bt;
  } else {
    fr[female] = br, fc[female] = bc, ft[female++] = bt;
  }
  memset(dis, -1, sizeof(dis));
  for ((i) = 0; (i) < (int)(n); (i)++) {
    for ((j) = 0; (j) < (int)(m); (j)++) bfs(i, j);
  }
  long long l = 0, r = (long long)1e12;
  while (l < r) {
    long long mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (l == (long long)1e12) {
    printf("-1\n");
  } else {
    printf("%lld\n", l);
  }
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}
