#include <bits/stdc++.h>
using namespace std;
int R, S, k;
char plan[107][107];
char road[1047];
int lx[300], ly[300];
int sx, sy, fx, fy;
int main() {
  scanf("%d%d%d", &R, &S, &k);
  for (int i = 0; i < (R); ++i) scanf("%s", plan[i + 1] + 1);
  scanf("%d%d %s %d%d", &sy, &sx, road, &fy, &fx);
  for (int i = 0; i < (107); ++i)
    for (int j = 0; j < (107); ++j) {
      ly[plan[i][j]] = i;
      lx[plan[i][j]] = j;
    }
  int x = sx, y = sy;
  int roL = strlen(road);
  for (int i = 0; i < (roL + 1); ++i) {
    int ny, nx;
    if (i < roL) {
      nx = lx[road[i]];
      ny = ly[road[i]];
    } else {
      ny = fy;
      nx = fx;
    }
    while (x + y != nx + ny) {
      if (plan[y][x] >= 'a')
        k--;
      else
        k -= plan[y][x] - '0';
      if (k < 0) break;
      if (x > nx) x--;
      if (y > ny) y--;
      if (nx > x) x++;
      if (ny > y) y++;
    }
  }
  printf("%d %d\n", y, x);
}
