#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, m, K;
char board[110][110], st[1010];
int rs, cs, re, ce;
int r[26], c[26];
int rp[1010], cp[1010];
inline int getL(char a) { return isalpha(a) ? 1 : a - '0'; }
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= n; i++) scanf("%s", board[i] + 1);
  scanf("%d%d%s%d%d", &rs, &cs, st, &re, &ce);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (isalpha(board[i][j]))
        r[board[i][j] - 'a'] = i, c[board[i][j] - 'a'] = j;
  int len;
  rp[0] = rs;
  cp[0] = cs;
  for (len = 0; st[len]; len++)
    rp[len + 1] = r[st[len] - 'a'], cp[len + 1] = c[st[len] - 'a'];
  len++;
  rp[len] = re;
  cp[len] = ce;
  for (int i = 0; i < len; i++) {
    int x = rp[i], y = cp[i];
    while (x != rp[i + 1] || y != cp[i + 1]) {
      if ((K -= getL(board[x][y])) < 0) return printf("%d %d\n", x, y), 0;
      if (x < rp[i + 1]) x++;
      if (x > rp[i + 1]) x--;
      if (y < cp[i + 1]) y++;
      if (y > cp[i + 1]) y--;
    }
  }
  printf("%d %d\n", re, ce);
  return 0;
}
