#include <bits/stdc++.h>
using namespace std;
struct node {
  int y, x;
};
int n, m, K;
char a[101][101];
node pos[26];
char seq[1005];
vector<node> vec;
int main() {
  node rs, re;
  scanf("%d %d %d", &n, &m, &K);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
    for (int j = 0; j < m; ++j) {
      if (a[i][j] >= 'a' && a[i][j] <= 'z') {
        pos[a[i][j] - 'a'].y = i;
        pos[a[i][j] - 'a'].x = j;
      }
    }
  }
  scanf("%d %d %s %d %d", &rs.y, &rs.x, seq, &re.y, &re.x);
  rs.y--;
  rs.x--;
  re.y--;
  re.x--;
  vec.clear();
  vec.push_back(rs);
  for (int i = 0; i < strlen(seq); ++i) {
    vec.push_back(pos[seq[i] - 'a']);
  }
  vec.push_back(re);
  int l = (int)vec.size();
  node res;
  vector<pair<int, int> > p;
  p.push_back(make_pair(rs.y, rs.x));
  for (int i = 1; i < l; ++i) {
    if (vec[i - 1].y == vec[i].y) {
      if (vec[i - 1].x < vec[i].x) {
        for (int j = vec[i - 1].x + 1; j <= vec[i].x; ++j)
          p.push_back(make_pair(vec[i].y, j));
      } else {
        for (int j = vec[i - 1].x - 1; j >= vec[i].x; --j)
          p.push_back(make_pair(vec[i].y, j));
      }
    } else {
      if (vec[i - 1].y < vec[i].y) {
        for (int j = vec[i - 1].y + 1; j <= vec[i].y; ++j)
          p.push_back(make_pair(j, vec[i].x));
      } else {
        for (int j = vec[i - 1].y - 1; j >= vec[i].y; --j)
          p.push_back(make_pair(j, vec[i].x));
      }
    }
  }
  int t = 0;
  int f = 0;
  for (int i = 0; i < (int)p.size(); ++i) {
    if (t == K) {
      res.y = p[i].first;
      res.x = p[i].second;
      f = 1;
      break;
    }
    char c = a[p[i].first][p[i].second];
    if (c >= 'a' && c <= 'z')
      t++;
    else
      t += c - '0';
    if (t > K) {
      res.y = p[i].first;
      res.x = p[i].second;
      f = 1;
      break;
    }
  }
  if (!f) {
    res.y = re.y;
    res.x = re.x;
  }
  printf("%d %d\n", res.y + 1, res.x + 1);
}
