#include <bits/stdc++.h>
using namespace std;
const int max_n = 100 + 10, max_m = 100 + 10, max_s = 1000 + 10;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
int n, m, minute, start_x, start_y, end_x, end_y, ans_x, ans_y;
char g[max_n][max_m], path[max_s];
int distances[max_n][max_m], cost[28][28];
pair<int, int> pos[28], pre[max_n][max_m];
bool is_in[max_n][max_m];
void compute_path(int id, int x, int y) {
  queue<pair<int, int> > q;
  memset(is_in, 0, sizeof(is_in));
  memset(distances, -1, sizeof(distances));
  q.push(make_pair(x, y));
  is_in[x][y] = true;
  distances[x][y] = 0;
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    int dis = distances[x][y];
    q.pop();
    is_in[x][y] = false;
    for (int i = 0; i < 4; ++i) {
      int next_x = x + dx[i], next_y = y + dy[i];
      if (next_x >= 0 && next_x < n && next_y >= 0 && next_y < m &&
          g[next_x][next_y] != '#') {
        int d = (isdigit(g[x][y]) ? g[x][y] - '0' : 1);
        if (distances[next_x][next_y] == -1 ||
            dis + d < distances[next_x][next_y]) {
          if (isdigit(g[next_x][next_y]) && !is_in[next_x][next_y]) {
            q.push(make_pair(next_x, next_y));
            is_in[next_x][next_y] = true;
          }
          distances[next_x][next_y] = dis + d;
          pre[next_x][next_y] = make_pair(x, y);
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (islower(g[i][j])) {
        cost[id][g[i][j] - 'a'] = distances[i][j];
      }
    }
  }
}
void compute_position() {
  memset(pos, -1, sizeof(pos));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (islower(g[i][j])) {
        pos[g[i][j] - 'a'] = make_pair(i, j);
      }
      if (i == start_x - 1 && j == start_y - 1) {
        pos[26] = make_pair(i, j);
      }
      if (i == end_x - 1 && j == end_y - 1) {
        pos[27] = make_pair(i, j);
      }
    }
  }
  for (int i = 0; i < 28; ++i) {
    if (pos[i].first != -1 && pos[i].second != -1) {
      compute_path(i, pos[i].first, pos[i].second);
    }
  }
  string s = path;
  s = (char)('z' + 1) + s + char('z' + 2);
  int sum = 0;
  for (int i = 0; i + 1 < s.size(); ++i) {
    int id1 = s[i] - 'a', id2 = s[i + 1] - 'a', c = cost[id1][id2];
    if (sum + c >= minute) {
      compute_path(id1, pos[id1].first, pos[id1].second);
      ans_x = pos[id2].first;
      ans_y = pos[id2].second;
      while (sum + distances[ans_x][ans_y] > minute) {
        pair<int, int> tmp = pre[ans_x][ans_y];
        ans_x = tmp.first;
        ans_y = tmp.second;
      }
      ++ans_x;
      ++ans_y;
      return;
    }
    sum += c;
  }
  ans_x = end_x;
  ans_y = end_y;
}
void solve() {
  scanf("%d%d%d", &n, &m, &minute);
  for (int i = 0; i < n; ++i) {
    scanf("%s", g[i]);
  }
  scanf("%d%d%s%d%d", &start_x, &start_y, path, &end_x, &end_y);
  compute_position();
  printf("%d %d\n", ans_x, ans_y);
}
int main() {
  solve();
  return 0;
}
