#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)((t).size()))); ++(i)) s << t[i] << " ";
  return s;
}
char s[107][128], str[1007];
pair<int, int> pos[256];
int cost(char c) {
  if (c >= '0' && c <= '9') return c - '0';
  return 1;
}
int sgn(int x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }
int main() {
  int(n), (m), (k);
  scanf("%d %d %d", &(n), &(m), &(k));
  for (int(i) = 1; (i) <= (n); ++(i)) scanf("%s", s[i] + 1);
  int(x), (y);
  scanf("%d %d", &(x), &(y));
  scanf("%s", str);
  int(endx), (endy);
  scanf("%d %d", &(endx), &(endy));
  for (int(i) = 1; (i) <= (n); ++(i))
    for (int(j) = 1; (j) <= (m); ++(j))
      if (s[i][j] >= 'a' && s[i][j] <= 'z') {
        pos[s[i][j]] = make_pair(i, j);
      }
  vector<pair<int, int> > points;
  for (char *t = str; *t; ++t) points.push_back(pos[*t]);
  points.push_back(make_pair(endx, endy));
  for (typeof(points.begin()) it = points.begin(); it != points.end(); it++) {
    int dx = sgn(it->first - x), dy = sgn(it->second - y);
    while (x != it->first || y != it->second) {
      k -= cost(s[x][y]);
      if (k < 0) {
        printf("%d %d\n", x, y);
        return 0;
      }
      x += dx;
      y += dy;
    }
  }
  printf("%d %d\n", x, y);
}
