#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 2000 + 5;
const int maxM = 1400 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int base = 701;
const int SQ = 500;
int head[maxN], cap[maxM], nex[maxM], to[maxM], cnt;
void add(int v, int u, int c) {
  nex[cnt] = head[v];
  cap[cnt] = c;
  to[cnt] = u;
  head[v] = cnt++;
  nex[cnt] = head[u];
  cap[cnt] = 0;
  to[cnt] = v;
  head[u] = cnt++;
}
int h[maxN], itr[maxN];
int source, sink;
int dfs(int v, int flow = mod) {
  if (v == sink) return flow;
  int ans = 0;
  while (itr[v] != -1) {
    int e = itr[v];
    if (cap[e] == 0 || h[to[e]] != h[v] + 1) {
      itr[v] = nex[itr[v]];
      continue;
    }
    int tmp = dfs(to[e], min(cap[e], flow));
    cap[e] -= tmp;
    cap[e ^ 1] += tmp;
    ans += tmp;
    flow -= tmp;
    if (flow == 0) break;
    itr[v] = nex[itr[v]];
  }
  return ans;
}
int que[maxN];
bool bfs() {
  int st = 0, en = 0;
  que[en++] = source;
  memset(h, 0, sizeof h);
  h[source] = 1;
  while (st < en) {
    int v = que[st++];
    for (int e = head[v]; e != -1; e = nex[e])
      if (cap[e] && h[to[e]] == 0) {
        h[to[e]] = h[v] + 1;
        que[en++] = to[e];
      }
  }
  if (h[sink] == 0) return false;
  return true;
}
int get_max_flow() {
  int res = 0;
  while (bfs()) {
    memcpy(itr, head, sizeof head);
    res += dfs(source);
  }
  return res;
}
long long dis[2][500][22][22];
char a[22][22];
pair<int, int> q[500];
int n, m;
bool is_ok(int x, int y) {
  if (x < 0 || y < 0 || n <= x || m <= y) return false;
  return true;
}
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
vector<pair<pair<int, int>, int> > v[2];
bool check(long long t) {
  memset(head, -1, sizeof head);
  cnt = 0;
  source = 0;
  sink = 2 * n * m + v[0].size() + v[1].size() + 1;
  for (int i = 1; i < (int)v[0].size() + 1; i++) add(source, i, 1);
  for (int i = 1; i < (int)v[1].size() + 1; i++)
    add(v[0].size() + 2 * n * m + i, sink, 1);
  for (int i = 0; i < (int)v[0].size(); i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < m; k++)
        if (dis[0][i][j][k] < 2000 &&
            (1LL) * dis[0][i][j][k] * v[0][i].second <= t)
          add(i + 1, v[0].size() + 1 + j * m + k, 1);
  for (int i = 0; i < (int)v[1].size(); i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < m; k++)
        if (dis[1][i][j][k] < 2000 &&
            (1LL) * dis[1][i][j][k] * v[1][i].second <= t)
          add(v[0].size() + n * m + 1 + j * m + k,
              v[0].size() + 2 * n * m + i + 1, 1);
  for (int i = 1; i < n * m + 1; i++)
    add(v[0].size() + i, v[0].size() + n * m + i, 1);
  int res = get_max_flow();
  if (res == (int)v[0].size()) return true;
  return false;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int male, female;
  cin >> n >> m >> male >> female;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int bx, by, bt;
  cin >> bx >> by >> bt;
  bx--;
  by--;
  for (int i = 0; i < male; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    x--;
    y--;
    v[0].push_back({{x, y}, t});
  }
  for (int i = 0; i < female; i++) {
    int x, y, t;
    cin >> x >> y >> t;
    x--;
    y--;
    v[1].push_back({{x, y}, t});
  }
  if (v[0].size() > v[1].size())
    v[1].push_back({{bx, by}, bt});
  else
    v[0].push_back({{bx, by}, bt});
  if (v[0].size() != v[1].size()) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < (int)v[i].size(); j++) {
      int x = v[i][j].first.first, y = v[i][j].first.second;
      int st = 0, en = 0;
      q[en++] = {x, y};
      for (int xx = 0; xx < n; xx++)
        for (int yy = 0; yy < m; yy++) dis[i][j][xx][yy] = 2000;
      dis[i][j][x][y] = 0;
      while (st < en) {
        int x0 = q[st].first, y0 = q[st].second;
        st++;
        for (int k = 0; k < 4; k++) {
          int vv = x0 + dx[k], u = y0 + dy[k];
          if (is_ok(vv, u) && a[vv][u] == '.' && dis[i][j][vv][u] == 2000) {
            dis[i][j][vv][u] = dis[i][j][x0][y0] + 1;
            q[en++] = {vv, u};
          }
        }
      }
    }
  long long lo = -1, hi = 1000LL * mod;
  while (hi - lo > 1) {
    long long mid = (hi + lo) >> 1;
    if (check(mid))
      hi = mid;
    else
      lo = mid;
  }
  if (hi == 1000LL * mod) {
    cout << -1 << endl;
    return 0;
  }
  cout << hi << endl;
  return 0;
}
