#include <bits/stdc++.h>
using namespace std;
template <int N, typename T>
struct MaxFlow {
  int l[N], tot, d[N], Q[N], s, t, u, v, src, sink, cur[N];
  struct Edge {
    int v, x;
    T cap;
  } E[1111111];
  void add(int u, int v, T cap) {
    E[tot] = (Edge){v, l[u], cap};
    l[u] = tot++;
    E[tot] = (Edge){u, l[v], 0};
    l[v] = tot++;
  }
  void init() {
    memset(l, -1, sizeof l);
    tot = 0;
  }
  bool bfs() {
    memset(d, -1, sizeof d);
    memcpy(cur, l, sizeof cur);
    d[src] = 0;
    s = t = 0;
    Q[t++] = src;
    while (s < t) {
      u = Q[s++];
      for (int i = l[u]; ~i; i = E[i].x) {
        v = E[i].v;
        if (d[v] == -1 && E[i].cap > 0) {
          Q[t++] = v;
          d[v] = d[u] + 1;
        }
      }
    }
    return d[sink] != -1;
  }
  T dfs(int u, T in) {
    if (u == sink) return in;
    T flow = 0, f;
    for (int i = l[u]; ~i; i = E[i].x) {
      v = E[i].v;
      if (d[v] == d[u] + 1 && E[i].cap) {
        if (f = dfs(v, min(in - flow, E[i].cap))) {
          flow += f;
          E[i].cap -= f;
          E[i ^ 1].cap += f;
          if (flow == in) break;
        }
      }
    }
    if (flow < in) d[u] = -1;
    return flow;
  }
  T dinic(int _src, int _sink) {
    src = _src;
    sink = _sink;
    T flow = 0;
    while (bfs()) flow += dfs(src, 123456789);
    return flow;
  }
};
const int N = 23;
MaxFlow<4 * N * N, int> F;
char field[N][N];
struct QQ {
  int x, y, t, Dist[N][N];
  void Scan() {
    scanf("%d%d%d", &x, &y, &t);
    x--;
    y--;
  }
} males[N * N], females[N * N], king;
const int inf = 1e9;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n, m;
int male, female;
void BFS(int x, int y, int Dist[][N]) {
  fill(Dist[0], Dist[N], inf);
  Dist[x][y] = 0;
  queue<int> Q;
  Q.push(x);
  Q.push(y);
  while (!Q.empty()) {
    x = Q.front();
    Q.pop();
    y = Q.front();
    Q.pop();
    for (int _ = 0; _ < 4; _++) {
      int xx = x + dx[_];
      int yy = y + dy[_];
      if (xx >= 0 && xx < n && yy >= 0 && yy < m && field[xx][yy] == '.') {
        if (Dist[xx][yy] > Dist[x][y] + 1) {
          Dist[xx][yy] = Dist[x][y] + 1;
          Q.push(xx);
          Q.push(yy);
        }
      }
    }
  }
}
bool check(long long need) {
  int src = 4 * n * m + 2, sink = src + 1;
  F.init();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (field[i][j] == '.') {
        F.add(i * m + j, i * m + j + n * m, 1);
        for (int _ = 0; _ < male; _++) {
          QQ &ie = males[_];
          if (ie.Dist[i][j] == inf) continue;
          if (ie.Dist[i][j] * 1LL * ie.t <= need) {
            F.add(_ + n * m * 2, i * m + j, 1);
          }
        }
        for (int _ = 0; _ < female; _++) {
          QQ &ie = females[_];
          if (ie.Dist[i][j] == inf) continue;
          if (ie.Dist[i][j] * 1LL * ie.t <= need) {
            F.add(i * m + j + n * m, _ + n * m * 3, 1);
          }
        }
        if (king.Dist[i][j] == inf) continue;
        if (female > male) {
          if (king.Dist[i][j] * 1LL * king.t <= need) {
            F.add(4 * n * m, i * m + j, 1);
          }
        } else {
          if (king.Dist[i][j] * 1LL * king.t <= need) {
            F.add(i * m + j + n * m, 4 * n * m, 1);
          }
        }
      }
    }
  }
  for (int _ = 0; _ < male; _++) {
    F.add(src, _ + n * m * 2, 1);
  }
  for (int _ = 0; _ < female; _++) {
    F.add(_ + n * m * 3, sink, 1);
  }
  if (female > male) {
    F.add(src, 4 * n * m, 1);
  } else {
    F.add(4 * n * m, sink, 1);
  }
  return F.dinic(src, sink) == max(male, female);
}
int main() {
  scanf("%d%d%d%d", &n, &m, &male, &female);
  F.init();
  for (int i = 0; i < n; i++) {
    scanf("%s", field[i]);
  }
  king.Scan();
  for (int i = 0; i < male; i++) {
    males[i].Scan();
  }
  for (int i = 0; i < female; i++) {
    females[i].Scan();
  }
  if (abs(male - female) != 1) {
    puts("-1");
  } else {
    BFS(king.x, king.y, king.Dist);
    for (int i = 0; i < male; i++) {
      BFS(males[i].x, males[i].y, males[i].Dist);
    }
    for (int i = 0; i < female; i++) {
      BFS(females[i].x, females[i].y, females[i].Dist);
    }
    long long left = 0, right = (n * m) * 1LL * inf;
    while (left < right) {
      long long middle = left + right >> 1;
      if (check(middle)) {
        right = middle;
      } else {
        left = middle + 1;
      }
    }
    if (check(left)) {
      printf("%I64d\n", left);
    } else
      puts("-1");
  }
  return 0;
}
