#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9);
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    pq;
const int dd[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
int n, m, k, tim;
pair<int, int> from[111][111];
int d[111][111], cost[111][111];
bool ok[111][111];
char second[111][111];
pair<int, int> pos[333];
string com;
inline bool exist(int &x, int &y) {
  return (x >= 0 && y >= 0 && x < n && y < m);
}
void go(pair<int, int> first, pair<int, int> t) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      ok[i][j] = (isdigit(second[i][j]) || make_pair(i, j) == t);
      d[i][j] = inf;
    }
  }
  d[first.first][first.second] = tim;
  pq.push(make_pair(tim, first));
  while (!pq.empty()) {
    pair<int, pair<int, int> > top = pq.top();
    pq.pop();
    int x = top.second.first;
    int y = top.second.second;
    int c = cost[x][y];
    if (d[x][y] < top.first) continue;
    for (int k = 0; k < 4; ++k) {
      int xx = x + dd[k][0];
      int yy = y + dd[k][1];
      if (!exist(xx, yy) || !ok[xx][yy]) continue;
      if (d[xx][yy] > d[x][y] + c) {
        d[xx][yy] = d[x][y] + c;
        from[xx][yy] = make_pair(x, y);
        pq.push(make_pair(d[xx][yy], make_pair(xx, yy)));
      }
    }
  }
  if (d[t.first][t.second] >= k) {
    while (true) {
      pair<int, int> p = from[t.first][t.second];
      if (d[p.first][p.second] + cost[p.first][p.second] > k) {
        t = p;
      } else
        break;
    }
    printf("%d %d\n", t.first + 1, t.second + 1);
    exit(0);
  }
  tim = d[t.first][t.second];
}
int main() {
  scanf("%d%d%d\n", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    gets(second[i]);
    for (int j = 0; j < m; ++j)
      if (isalpha(second[i][j])) pos[second[i][j]] = make_pair(i, j);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (isalpha(second[i][j]))
        cost[i][j] = 1;
      else if (isdigit(second[i][j]))
        cost[i][j] = second[i][j] - '0';
    }
  }
  pair<int, int> first, t;
  cin >> first.first >> first.second;
  --first.first, --first.second;
  cin >> com;
  cin >> t.first >> t.second;
  --t.first, --t.second;
  for (int i = 0; i < com.size(); ++i) {
    pair<int, int> to = pos[com[i]];
    go(first, to);
    first = to;
  }
  go(first, t);
  printf("%d %d\n", t.first + 1, t.second + 1);
  return 0;
}
