#include <bits/stdc++.h>
using namespace std;
char A[1 << 10][1 << 10];
int X[1 << 10];
int Y[1 << 10];
int XX[1 << 10];
int YY[1 << 10];
int Sign(int a) { return a == 0 ? 0 : (a < 0 ? -1 : 1); }
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int i, j;
  for (i = (0); i < (n); ++i) scanf("%s", A[i]);
  for (i = (0); i < (n); ++i)
    for (j = (0); j < (m); ++j)
      if ('a' <= A[i][j] && A[i][j] <= 'z') {
        X[A[i][j] - 'a'] = i;
        Y[A[i][j] - 'a'] = j;
      }
  int x, y;
  char buf[1 << 10];
  scanf("%d%d%s", &x, &y, buf);
  --x;
  --y;
  int len = strlen(buf);
  int time = 0;
  for (i = (0); i < (len); ++i) {
    XX[i] = X[buf[i] - 'a'];
    YY[i] = Y[buf[i] - 'a'];
  }
  scanf("%d%d", &XX[len], &YY[len]);
  --XX[len];
  --YY[len];
  pair<int, int> res(XX[len], YY[len]);
  for (i = (0); i < (len + 1); ++i) {
    int xx = XX[i];
    int yy = YY[i];
    int dx = Sign(xx - x);
    int dy = Sign(yy - y);
    if (dx == 0 && dy == 0) continue;
    while (x != xx || y != yy) {
      int t = 1;
      if ('1' <= A[x][y] && A[x][y] <= '9') t = A[x][y] - '0';
      if (time <= k && k < time + t) res = pair<int, int>(x, y);
      time += t;
      x += dx;
      y += dy;
    }
  }
  printf("%d %d\n", res.first + 1, res.second + 1);
  return 0;
};
