#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, sz;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k >> s >> sz;
  int xx = -1, yy = -1;
  vector<vector<char>> a(n, vector<char>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'P') {
        xx = i;
        yy = j;
      }
    }
  }
  vector<char> wind(sz);
  for (int i = 0; i < sz; i++) cin >> wind[i];
  vector<pair<int, int>> store(s);
  vector<int> days(s);
  for (int i = 0; i < s; i++) {
    cin >> store[i].first >> store[i].second;
    cin >> days[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'M') store.emplace_back(i, j);
    }
  }
  days.push_back(0);
  s++;
  string pat = "NSEWC";
  vector<vector<int>> to(sz, vector<int>(5, -1));
  for (int i = sz - 1; i >= 0; i--) {
    if (i < sz - 1) to[i] = to[i + 1];
    for (int j = 0; j < 5; j++) {
      if (pat[j] == wind[i]) to[i][j] = i;
    }
  }
  vector<int> dx = {-1, 1, 0, 0, 0};
  vector<int> dy = {0, 0, 1, -1, 0};
  auto calc = [&](int ix, int iy, int d) {
    vector<vector<int>> ret(n, vector<int>(m, INT_MAX));
    ret[ix][iy] = d;
    set<pair<int, pair<int, int>>> cur;
    cur.insert({d, {ix, iy}});
    vector<vector<int>> alive(n, vector<int>(m));
    while (cur.size()) {
      int x = cur.begin()->second.first;
      int y = cur.begin()->second.second;
      cur.erase(cur.begin());
      if (alive[x][y]) continue;
      alive[x][y] = 1;
      int dep = ret[x][y];
      if (dep >= sz) break;
      for (int i = 0; i < 5; i++) {
        if (to[dep][i] == -1) continue;
        for (int j = 0; j < 5; j++) {
          int sx = x + dx[i] + dx[j];
          int sy = y + dy[i] + dy[j];
          if (sx == x && sy == y) continue;
          if (sx < 0 || sx >= n || sy < 0 || sy >= m || a[sx][sy] == 'L')
            continue;
          if (abs(x - sx) + abs(y - sy) == 2) {
            if (sx == x || sy == y) {
              if (a[(x + sx) / 2][(y + sy) / 2] == 'L') continue;
            } else if (a[x][sy] == 'L' && a[sx][y] == 'L')
              continue;
          }
          if (to[dep][i] + 1 < ret[sx][sy]) {
            ret[sx][sy] = to[dep][i] + 1;
            cur.insert({ret[sx][sy], {sx, sy}});
          }
        }
      }
    }
    return ret;
  };
  vector<int> dep(s);
  vector<vector<int>> g(s);
  for (int i = 0; i < s; i++) {
    auto ret = calc(store[i].first, store[i].second, days[i]);
    dep[i] = ret[xx][yy];
    if (dep[i] - days[i] > k) dep[i] = INT_MAX;
    for (int j = 0; j < s; j++) {
      if (days[i] >= days[j]) continue;
      int sx = store[j].first;
      int sy = store[j].second;
      if (ret[sx][sy] <= min(days[j], days[i] + k)) g[i].push_back(j);
    }
  }
  int ret = INT_MAX;
  vector<int> reachable(s);
  vector<int> id(s);
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(), [&](int i, int j) {
    return make_pair(-i, days[i]) < make_pair(-j, days[j]);
  });
  reachable[s - 1] = 1;
  for (int i : id) {
    for (int j : g[i]) {
      reachable[j] |= reachable[i];
    }
  }
  for (int i = 0; i < s; i++) {
    if (reachable[i]) ret = min(ret, dep[i]);
  }
  if (ret > sz) ret = -1;
  cout << ret;
  return 0;
}
