#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
};
queue<node> q;
int wayx[10] = {-1, 0, 0, 1};
int wayy[10] = {0, -1, 1, 0};
int dis[110][110], in[110][110];
char s[110][110];
char ss[1010];
int m, n;
node pre[110][110], tp[10010];
void ck(int x1, int y1, int x2, int y2, node *pa, int &len, int &len2) {
  memset(dis, -1, sizeof(dis));
  memset(in, 0, sizeof(in));
  dis[x1][y1] = 0;
  node ss;
  ss.x = x1;
  ss.y = y1;
  while (!q.empty()) q.pop();
  q.push(ss);
  in[x1][y1] = 1;
  pre[x1][y1] = ss;
  while (!q.empty()) {
    node hh = q.front();
    q.pop();
    in[hh.x][hh.y] = 0;
    for (int j = 0; j < 4; j++) {
      int tx = hh.x + wayx[j];
      int ty = hh.y + wayy[j];
      if (tx < 0 || tx >= m || ty < 0 || ty >= n) continue;
      if (s[tx][ty] == '#') continue;
      if (s[x2][y2] >= 'a' && s[x2][y2] <= 'z' && s[tx][ty] >= 'a' &&
          s[tx][ty] <= 'z' && s[tx][ty] != s[x2][y2])
        continue;
      int delta =
          (s[hh.x][hh.y] >= '0' && s[hh.x][hh.y] <= '9' ? s[hh.x][hh.y] - '0'
                                                        : 1);
      if (dis[tx][ty] == -1 || dis[tx][ty] >= dis[hh.x][hh.y] + delta) {
        dis[tx][ty] = dis[hh.x][hh.y] + delta;
        pre[tx][ty] = hh;
        if (!in[tx][ty]) {
          in[tx][ty] = 1;
          node ne;
          ne.x = tx;
          ne.y = ty;
          q.push(ne);
        }
      }
    }
  }
  if (dis[x2][y2] == -1) return;
  len = 0;
  node now;
  now.x = x2;
  now.y = y2;
  while (now.x != x1 || now.y != y1) {
    tp[len++] = now;
    now = pre[now.x][now.y];
  }
  pa[0] = now;
  for (int i = 1; i <= len; i++) pa[i] = tp[len - i];
  len2 = dis[x2][y2];
}
int rr[30], cc[30];
node x[26][26][10010], p1[10010], p2[10010];
int ll[30][30], tll1[30][30];
int l1, l2, ll1, ll2;
int main() {
  int tt;
  scanf("%d%d%d", &m, &n, &tt);
  for (int i = 0; i < m; i++) scanf("%s", s[i]);
  int rs, cs, re, ce;
  scanf("%d%d%s%d%d", &rs, &cs, ss, &re, &ce);
  rs--;
  cs--;
  re--;
  ce--;
  int len = strlen(ss);
  memset(rr, -1, sizeof(rr));
  memset(cc, -1, sizeof(cc));
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) {
      if (s[i][j] >= 'a' && s[i][j] <= 'z') {
        rr[s[i][j] - 'a'] = i;
        cc[s[i][j] - 'a'] = j;
      }
    }
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) {
      if (rr[i] == -1) continue;
      if (cc[j] == -1) continue;
      ck(rr[i], cc[i], rr[j], cc[j], x[i][j], ll[i][j], tll1[i][j]);
    }
  int now = tt;
  ck(rs, cs, rr[ss[0] - 'a'], cc[ss[0] - 'a'], p1, l1, ll1);
  ck(rr[ss[len - 1] - 'a'], cc[ss[len - 1] - 'a'], re, ce, p2, l2, ll2);
  if (now < ll1) {
    for (int i = 0; i < l1; i++) {
      int delta, tx = p1[i].x, ty = p1[i].y;
      delta = (s[tx][ty] >= '0' && s[tx][ty] <= '9' ? s[tx][ty] - '0' : 1);
      if (now < delta) {
        printf("%d %d\n", p1[i].x + 1, p1[i].y + 1);
        return 0;
      } else
        now -= delta;
    }
    while (1)
      ;
  } else {
    now -= ll1;
    for (int i = 0; i < len - 1; i++) {
      if (now >= tll1[ss[i] - 'a'][ss[i + 1] - 'a']) {
        now -= tll1[ss[i] - 'a'][ss[i + 1] - 'a'];
        continue;
      }
      for (int j = 0; j < ll[ss[i] - 'a'][ss[i + 1] - 'a']; j++) {
        int delta, tx = x[ss[i] - 'a'][ss[i + 1] - 'a'][j].x,
                   ty = x[ss[i] - 'a'][ss[i + 1] - 'a'][j].y;
        delta = (s[tx][ty] >= '0' && s[tx][ty] <= '9' ? s[tx][ty] - '0' : 1);
        if (now < delta) {
          printf("%d %d\n", x[ss[i] - 'a'][ss[i + 1] - 'a'][j].x + 1,
                 x[ss[i] - 'a'][ss[i + 1] - 'a'][j].y + 1);
          return 0;
        } else
          now -= delta;
      }
      while (1)
        ;
    }
    if (now < ll2) {
      for (int i = 0; i < l2; i++) {
        int delta, tx = p2[i].x, ty = p2[i].y;
        delta = (s[tx][ty] >= '0' && s[tx][ty] <= '9' ? s[tx][ty] - '0' : 1);
        if (now < delta) {
          printf("%d %d\n", p2[i].x + 1, p2[i].y + 1);
          return 0;
        } else
          now -= delta;
      }
      while (1)
        ;
    } else
      printf("%d %d\n", re + 1, ce + 1);
  }
  return 0;
}
