#include <bits/stdc++.h>
using namespace std;
int n, m, k;
char B[111][111];
pair<int, int> X[333];
string go;
int sx, sy, ex, ey;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) scanf("%s", B[i] + 1);
  cin >> sx >> sy >> go >> ex >> ey;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (B[i][j] >= 'a' && B[i][j] <= 'z') X[B[i][j]] = make_pair(i, j);
  int x = sx, y = sy;
  for (int i = 0; i < (int)go.size(); ++i) {
    int nx = X[go[i]].first;
    int ny = X[go[i]].second;
    if (nx < x) {
      for (int j = x; j >= nx + 1; --j) {
        int t;
        if (B[j][y] >= '1' && B[j][y] <= '9')
          t = B[j][y] - '0';
        else
          t = 1;
        if (t > k) {
          printf("%d %d", j, y);
          return 0;
        } else
          k -= t, x = j - 1;
      }
    } else if (nx > x) {
      for (int j = x; j <= nx - 1; ++j) {
        int t;
        if (B[j][y] >= '1' && B[j][y] <= '9')
          t = B[j][y] - '0';
        else
          t = 1;
        if (t > k) {
          printf("%d %d", j, y);
          return 0;
        } else
          k -= t, x = j + 1;
      }
    } else if (ny < y) {
      for (int j = y; j >= ny + 1; --j) {
        int t;
        if (B[x][j] >= '1' && B[x][j] <= '9')
          t = B[x][j] - '0';
        else
          t = 1;
        if (t > k) {
          printf("%d %d", x, j);
          return 0;
        } else
          k -= t, y = j - 1;
      }
    } else if (ny > y) {
      for (int j = y; j <= ny - 1; ++j) {
        int t;
        if (B[x][j] >= '1' && B[x][j] <= '9')
          t = B[x][j] - '0';
        else
          t = 1;
        if (t > k) {
          printf("%d %d", x, j);
          return 0;
        } else
          k -= t, y = j + 1;
      }
    }
  }
  printf("%d %d", ex, ey);
  return 0;
}
