#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[(1 << 7)];
int n, m, k, sx, sy, fx, fy;
char s[(1 << 10)];
char a[(1 << 7)][(1 << 7)];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= 'a' && a[i][j] <= 'z') {
        p[a[i][j] - 'a'] = make_pair(i, j);
        a[i][j] = 1;
      } else {
        a[i][j] -= '0';
      }
    }
  }
  int t1;
  scanf("%d%d%s%d%d", &sx, &sy, s + 1, &fx, &fy);
  p[26] = make_pair(fx, fy);
  t1 = strlen(s + 1) + 1;
  s[t1] = 26;
  for (int i = 1; i < t1; i++) {
    s[i] -= 'a';
  }
  for (int i = 1; i <= t1 && k > 0; i++) {
    while (sx != p[s[i]].first || sy != p[s[i]].second) {
      k -= a[sx][sy];
      if (k < 0) {
        break;
      }
      if (sx > p[s[i]].first) {
        sx--;
      }
      if (sx < p[s[i]].first) {
        sx++;
      }
      if (sy > p[s[i]].second) {
        sy--;
      }
      if (sy < p[s[i]].second) {
        sy++;
      }
    }
  }
  printf("%d %d\n", sx, sy);
  return 0;
}
