#include <bits/stdc++.h>
using namespace std;
const int NMAX = 105;
const int PMAX = 1e4 + 5;
const int JMAX = 30;
const int oo = 1 << 30;
const int cx[] = {-1, 1, 0, 0};
const int cy[] = {0, 0, -1, 1};
int N, M, K;
char a[NMAX][NMAX];
int id[NMAX][NMAX];
int dst[JMAX][JMAX];
int P, J;
int val[PMAX];
pair<int, int> pos[PMAX];
int d[PMAX], lst[PMAX];
vector<int> edg[PMAX];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    hp;
void dijkstra(int nod) {
  for (int i = 1; i <= P; i++) d[i] = oo;
  d[nod] = 0;
  while (!hp.empty()) hp.pop();
  hp.push({0, nod});
  int NOD = nod;
  while (!hp.empty()) {
    int nod, dst;
    tie(dst, nod) = hp.top();
    hp.pop();
    if (dst != d[nod]) continue;
    if (nod <= 26 && nod != NOD) continue;
    for (auto nxt : edg[nod])
      if (d[nxt] > dst + val[nod]) {
        d[nxt] = dst + val[nod];
        lst[nxt] = nod;
        hp.push({d[nxt], nxt});
      }
  }
}
void solve(int s, int f) {
  int dist = 0;
  if (s > J || f > J) {
    dijkstra(s);
    dist = d[f];
  } else
    dist = dst[s][f];
  if (K > dist) {
    K -= dist;
    return;
  }
  dijkstra(s);
  int nod = f;
  while (d[nod] > K) nod = lst[nod];
  printf("%d %d\n", pos[nod].first, pos[nod].second);
  exit(0);
}
int main() {
  scanf("%d%d%d\n", &N, &M, &K);
  P = 26;
  for (int i = 1; i <= N; i++) {
    scanf("%s\n", a[i] + 1);
    for (int j = 1; j <= M; j++)
      if (a[i][j] != '#') {
        if ('a' <= a[i][j] && a[i][j] <= 'z') {
          id[i][j] = a[i][j] - 'a' + 1;
          val[a[i][j] - 'a' + 1] = 1;
        } else {
          id[i][j] = ++P;
          val[P] = a[i][j] - '0';
        }
        pos[id[i][j]] = {i, j};
      }
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      if (id[i][j] > 0) {
        for (int k = 0; k < 4; k++) {
          int x = i + cx[k], y = j + cy[k];
          if (x < 1 || x > N || y < 1 || y > M) continue;
          if (!id[x][y]) continue;
          edg[id[i][j]].push_back(id[x][y]);
        }
      }
  J = 26;
  for (int i = 1; i <= J; i++) {
    dijkstra(i);
    for (int j = 1; j <= J; j++) dst[i][j] = d[j];
  }
  int xs, ys, xf, yf;
  scanf("%d%d", &xs, &ys);
  string pth;
  cin >> pth;
  scanf("%d%d", &xf, &yf);
  vector<pair<int, int> > path;
  path.push_back({id[xs][ys], pth[0] - 'a' + 1});
  for (int i = 0; i + 1 < pth.size(); i++)
    path.push_back({pth[i] - 'a' + 1, pth[i + 1] - 'a' + 1});
  path.push_back({pth.back() - 'a' + 1, id[xf][yf]});
  for (auto pr : path) solve(pr.first, pr.second);
  printf("%d %d\n", xf, yf);
  return 0;
}
