#include <bits/stdc++.h>
using namespace std;
char g[128][128];
inline int sgn(int n) { return (n > 0) - (n < 0); }
void go(int &x0, int &y0, int x1, int y1, int &k) {
  int dx = sgn(x1 - x0), dy = sgn(y1 - y0);
  while (x0 != x1 || y0 != y1) {
    if (k < g[x0][y0]) return;
    k -= g[x0][y0];
    x0 += dx;
    y0 += dy;
  }
}
int main() {
  int n, m, k;
  int x[128], y[128];
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", g[i] + 1);
    for (int j = 1; j <= m; ++j) {
      if (islower(g[i][j]))
        x[g[i][j]] = i, y[g[i][j]] = j, g[i][j] = 1;
      else
        g[i][j] -= '0';
    }
  }
  int rs, cs, re, ce;
  char s[1024];
  scanf("%d%d%s%d%d", &rs, &cs, s, &re, &ce);
  for (int i = 0; s[i]; ++i) go(rs, cs, x[s[i]], y[s[i]], k);
  go(rs, cs, re, ce, k);
  printf("%d %d\n", rs, cs);
}
