#include <bits/stdc++.h>
using namespace std;
inline int nextint(void) {
  int x;
  scanf("%d", &x);
  return (x);
}
inline pair<int, int> nextii(void) {
  int x = nextint();
  int y = nextint();
  return (pair<int, int>(x, y));
}
char a[111][111];
int m, n, q, l;
pair<int, int> add[111], sta, fin;
char way[111 * 111];
void init(void) {
  m = nextint();
  n = nextint();
  q = nextint();
  for (int i = (1), _b = (m); i <= _b; i = i + 1) scanf("%s", a[i] + 1);
  for (int i = (1), _b = (m); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if ('a' <= a[i][j] && a[i][j] <= 'z')
        add[a[i][j] - 'a'] = pair<int, int>(i, j);
  sta = nextii();
  scanf("%s", way + 1);
  l = strlen(way + 1);
  fin = nextii();
}
inline int togo(int x, int y) {
  if ('0' <= a[x][y] && a[x][y] <= '9') return (a[x][y] - '0');
  return (1);
}
void process(void) {
  pair<int, int> cur, next;
  cur = sta;
  vector<pair<int, int> > v;
  for (int i = (1), _b = (l + 1); i <= _b; i = i + 1) {
    next = i > l ? fin : add[way[i] - 'a'];
    if (cur.first == next.first) {
      for (int y = (cur.second + 1), _b = (next.second); y <= _b; y = y + 1)
        v.push_back(pair<int, int>(cur.first, y));
      for (int y = (cur.second - 1), _a = (next.second); y >= _a; y = y - 1)
        v.push_back(pair<int, int>(cur.first, y));
    } else {
      for (int x = (cur.first + 1), _b = (next.first); x <= _b; x = x + 1)
        v.push_back(pair<int, int>(x, cur.second));
      for (int x = (cur.first - 1), _a = (next.first); x >= _a; x = x - 1)
        v.push_back(pair<int, int>(x, cur.second));
    }
    cur = next;
  }
  cur = sta;
  for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++) {
    if (togo(cur.first, cur.second) > q) {
      printf("%d %d", cur.first, cur.second);
      return;
    }
    q -= togo(cur.first, cur.second);
    cur = *it;
  }
  printf("%d %d", fin.first, fin.second);
}
int main(void) {
  init();
  process();
  return 0;
}
