#include <bits/stdc++.h>
using namespace std;
char s[110][110], str[1100];
int n, m, k;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int X[30], Y[30], SS[1100];
int fdir(int x, int y, int nx, int ny) {
  for (int l = 0; l < 4; l++)
    for (int k = 0; k < 1100; k++)
      if (x + k * dx[l] == nx && y + k * dy[l] == ny) return l;
  assert(0);
}
void move(int x, int y, int xx, int yy) {
  int dir = fdir(x, y, xx, yy);
  int st = abs(x - xx) + abs(y - yy);
  while (st > 0) {
    int t = 1;
    if (s[x][y] >= '0' && s[x][y] <= '9') t = (int)(s[x][y] - '0');
    if (k < t) {
      printf("%d %d\n", x, y);
      exit(0);
    }
    x += dx[dir], y += dy[dir], k -= t, st--;
  }
}
int main() {
  int i, id, j, len, sx, sy, fx, fy;
  scanf("%d%d%d ", &n, &m, &k);
  for (i = 0; i < n; i++) gets(s[i + 1] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (s[i][j] >= 'a' && s[i][j] <= 'z') {
        id = (int)(s[i][j] - 'a'), X[id] = i, Y[id] = j;
      }
  scanf("%d%d %s %d%d", &sx, &sy, str, &fx, &fy), len = strlen(str);
  for (i = 0; i < len; i++) SS[i] = (int)(str[i] - 'a');
  move(sx, sy, X[SS[0]], Y[SS[0]]);
  for (i = 0; i < len - 1; i++)
    move(X[SS[i]], Y[SS[i]], X[SS[i + 1]], Y[SS[i + 1]]);
  move(X[SS[len - 1]], Y[SS[len - 1]], fx, fy);
  printf("%d %d\n", fx, fy);
  return 0;
}
