#include <bits/stdc++.h>
using namespace std;
struct State {
  int time;
  int x, y;
};
bool operator<(const State &a, const State &b) { return a.time > b.time; }
void output(int x, int y);
char MAP[200][200];
int H, W, k;
int jx[30], jy[30];
int dist[30][30];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int INF = 99999999;
void dijkstra(int k) {
  if (jx[k] == -1) return;
  int cost[200][200];
  for (int i = 0; i < (int)W; i++)
    for (int j = 0; j < (int)H; j++) {
      cost[i][j] = INF;
    }
  cost[jx[k]][jy[k]] = 0;
  priority_queue<State> que;
  que.push((State){0, jx[k], jy[k]});
  while (!que.empty()) {
    State now = que.top();
    que.pop();
    int movecost = 1;
    if (isdigit(MAP[now.x][now.y])) {
      movecost = MAP[now.x][now.y] - '0';
    }
    if (islower(MAP[now.x][now.y]) && now.time != 0) continue;
    if (cost[now.x][now.y] < now.time) continue;
    for (int q = 0; q < (int)4; q++) {
      int nx = now.x + dx[q], ny = now.y + dy[q];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && MAP[nx][ny] != '#') {
        if (cost[nx][ny] > cost[now.x][now.y] + movecost) {
          cost[nx][ny] = cost[now.x][now.y] + movecost;
          que.push((State){cost[nx][ny], nx, ny});
        }
      }
    }
  }
  for (int i = 0; i < (int)30; i++) {
    if (jx[i] == -1) continue;
    dist[k][i] = cost[jx[i]][jy[i]];
  }
}
void solve(int s, int t, int remain) {
  string k;
  int cost[200][200];
  pair<int, int> back[200][200];
  for (int i = 0; i < (int)W; i++)
    for (int j = 0; j < (int)H; j++) {
      cost[i][j] = INF;
    }
  cost[jx[s]][jy[s]] = 0;
  priority_queue<State> que;
  que.push((State){0, jx[s], jy[s]});
  while (!que.empty()) {
    State now = que.top();
    que.pop();
    int movecost = 1;
    if (isdigit(MAP[now.x][now.y])) {
      movecost = MAP[now.x][now.y] - '0';
    }
    if (islower(MAP[now.x][now.y]) && now.time != 0) continue;
    if (cost[now.x][now.y] < now.time) continue;
    for (int k = 0; k < (int)4; k++) {
      int nx = now.x + dx[k], ny = now.y + dy[k];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && MAP[nx][ny] != '#') {
        if (cost[nx][ny] > cost[now.x][now.y] + movecost) {
          cost[nx][ny] = cost[now.x][now.y] + movecost;
          back[nx][ny] = pair<int, int>(now.x, now.y);
          que.push((State){cost[nx][ny], nx, ny});
        }
      }
    }
  }
  vector<pair<int, int> > pts;
  int kx = jx[t], ky = jy[t];
  while (kx != jx[s] || ky != jy[s]) {
    pts.push_back(pair<int, int>(kx, ky));
    pair<int, int> b = back[kx][ky];
    kx = b.first;
    ky = b.second;
  }
  pts.push_back(pair<int, int>(jx[s], jy[s]));
  std::reverse(pts.begin(), pts.end());
  int cs = 0;
  for (int i = 0; i < (int)pts.size() - 1; i++) {
    int movecost = 1;
    int xx = pts[i].first, yy = pts[i].second;
    if (isdigit(MAP[xx][yy])) {
      movecost = MAP[xx][yy] - '0';
    }
    if (remain < movecost) {
      output(xx, yy);
      return;
    }
    cs += movecost;
    if (remain -= movecost) {
    }
  }
  output(jx[t], jy[t]);
}
void output(int x, int y) { cout << y + 1 << " " << x + 1 << endl; }
int main() {
  cin >> H >> W >> k;
  memset(jx, -1, sizeof(jx));
  for (int i = 0; i < (int)H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < (int)W; j++) {
      MAP[j][i] = s[j];
      if (islower(MAP[j][i])) {
        jx[MAP[j][i] - 'a'] = j;
        jy[MAP[j][i] - 'a'] = i;
      }
    }
  }
  int sx, sy;
  string s;
  int gx, gy;
  cin >> sy >> sx >> s >> gy >> gx;
  sx--;
  sy--;
  gx--;
  gy--;
  jx[26] = sx;
  jy[26] = sy;
  jx[27] = gx;
  jy[27] = gy;
  for (int i = 0; i < (int)30; i++)
    for (int j = 0; j < (int)30; j++) {
      dist[i][j] = INF;
    }
  for (int i = 0; i < (int)30; i++) {
    dijkstra(i);
  }
  vector<int> seq;
  seq.push_back(26);
  for (int i = 0; i < (int)s.size(); i++) {
    seq.push_back(s[i] - 'a');
  }
  seq.push_back(27);
  for (int i = 0; i < (int)seq.size() - 1; i++) {
    k -= dist[seq[i]][seq[i + 1]];
    if (k < 0) {
      solve(seq[i], seq[i + 1], k + dist[seq[i]][seq[i + 1]]);
      return 0;
    }
  }
  output(gx, gy);
  return 0;
}
