#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int incx[] = {1, -1, 0, 0};
const int incy[] = {0, 0, -1, 1};
vector<string> M;
int n, m;
int cost(char c) {
  if (c >= 'a' and c <= 'z') return 1;
  return c - '0';
}
vector<vector<int> > dijkstra(int sx, int sy,
                              vector<vector<pair<int, int> > >& padre) {
  priority_queue<pair<int, pair<int, int> > > Q;
  vector<vector<int> > d(n, vector<int>(m, INF));
  d[sx][sy] = 0;
  Q.push(pair<int, pair<int, int> >(0, pair<int, int>(sx, sy)));
  while (not Q.empty()) {
    int x = Q.top().second.first, y = Q.top().second.second,
        dist = -Q.top().first;
    Q.pop();
    if (dist != d[x][y]) continue;
    if (dist != 0 and M[x][y] >= 'a' and M[x][y] <= 'z') continue;
    for (int i = 0; i < 4; ++i) {
      int nx = x + incx[i], ny = y + incy[i];
      if (nx < 0 or nx >= n or ny < 0 or ny >= m or M[nx][ny] == '#') continue;
      if (d[nx][ny] > d[x][y] + cost(M[x][y])) {
        d[nx][ny] = d[x][y] + cost(M[x][y]);
        Q.push(pair<int, pair<int, int> >(-d[nx][ny], pair<int, int>(nx, ny)));
        padre[nx][ny] = pair<int, int>(x, y);
      }
    }
  }
  return d;
}
void solve(vector<vector<pair<int, int> > >& padre, int sx, int sy, int k,
           int tx, int ty) {
  vector<pair<int, int> > cami;
  cami.push_back(pair<int, int>(tx, ty));
  while (cami.back() != pair<int, int>(sx, sy))
    cami.push_back(padre[cami.back().first][cami.back().second]);
  bool fin = false;
  reverse(cami.begin(), cami.end());
  for (int i = 0; i < cami.size() and not fin; ++i) {
    int c = cost(M[cami[i].first][cami[i].second]);
    if (c > k) {
      cout << cami[i].first + 1 << " " << cami[i].second + 1 << endl;
      fin = true;
    } else
      k -= c;
  }
  if (not fin) cout << tx + 1 << " " << ty + 1 << endl;
}
int main() {
  int k;
  cin >> n >> m >> k;
  M = vector<string>(n);
  for (int i = 0; i < n; ++i) cin >> M[i];
  vector<vector<vector<int> > > d('z' - 'a' + 1,
                                  vector<vector<int> >(n, vector<int>(m, INF)));
  vector<vector<vector<pair<int, int> > > > padre(
      'z' - 'a' + 1,
      vector<vector<pair<int, int> > >(n, vector<pair<int, int> >(m)));
  vector<int> X('z' - 'a' + 1), Y('z' - 'a' + 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (M[i][j] >= 'a' and M[i][j] <= 'z') {
        d[M[i][j] - 'a'] = dijkstra(i, j, padre[M[i][j] - 'a']);
        X[M[i][j] - 'a'] = i;
        Y[M[i][j] - 'a'] = j;
      }
    }
  }
  int sx, sy, tx, ty;
  string s;
  cin >> sx >> sy >> s >> tx >> ty;
  --sx;
  --sy;
  --tx;
  --ty;
  vector<vector<pair<int, int> > > paux(n, vector<pair<int, int> >(m));
  vector<vector<int> > daux = dijkstra(sx, sy, paux);
  if (daux[X[s[0] - 'a']][Y[s[0] - 'a']] > k)
    solve(paux, sx, sy, k, X[s[0] - 'a'], Y[s[0] - 'a']);
  else {
    bool fin = false;
    k -= daux[X[s[0] - 'a']][Y[s[0] - 'a']];
    for (int i = 0; i + 1 < s.size(); ++i) {
      if (d[s[i] - 'a'][X[s[i + 1] - 'a']][Y[s[i + 1] - 'a']] > k) {
        solve(padre[s[i] - 'a'], X[s[i] - 'a'], Y[s[i] - 'a'], k,
              X[s[i + 1] - 'a'], Y[s[i + 1] - 'a']);
        fin = true;
        break;
      }
      k -= d[s[i] - 'a'][X[s[i + 1] - 'a']][Y[s[i + 1] - 'a']];
    }
    if (not fin)
      solve(padre[s[s.size() - 1] - 'a'], X[s[s.size() - 1] - 'a'],
            Y[s[s.size() - 1] - 'a'], k, tx, ty);
  }
}
