#include <bits/stdc++.h>
using namespace std;
char a[110][110];
int b[28][28][110 * 110], c[28][28];
struct note {
  int x, y;
} poi[28], st, en;
int n, m, k;
char s[110 * 110];
bool vis[110][110];
struct tree {
  int x, y, c;
  tree() {}
  tree(int x, int y, int c) : x(x), y(y), c(c) {}
  bool operator<(const tree& o) const { return c > o.c; }
};
struct step {
  int x, v;
} las[110][110];
priority_queue<tree> q;
const int fx[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
bool okay(int x, int y) { return x >= 0 && x < m && y >= 0 && y < n; }
void getlength(int ss, int ee) {
  if (poi[ss].x == poi[ee].x && poi[ss].y == poi[ee].y) {
    return;
  }
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) q.pop();
  vis[poi[ss].x][poi[ss].y] = true;
  q.push(tree(poi[ss].x, poi[ss].y, 0));
  las[poi[ss].x][poi[ss].y].v = 0;
  while (!q.empty()) {
    tree pre = q.top();
    q.pop();
    for (int i = 0; i < 4; i++) {
      int tx = pre.x + fx[i][0];
      int ty = pre.y + fx[i][1];
      if (!vis[tx][ty] && okay(tx, ty) && a[tx][ty] != '#') {
        vis[tx][ty] = true;
        las[tx][ty].x = i;
        las[tx][ty].v = las[pre.x][pre.y].v + 1;
        if (vis[poi[ee].x][poi[ee].y]) {
          break;
        }
        q.push(tree(tx, ty, pre.c + 1));
      }
    }
    if (vis[poi[ee].x][poi[ee].y]) {
      break;
    }
  }
  c[ss][ee] = las[poi[ee].x][poi[ee].y].v;
  int xx = poi[ee].x, yy = poi[ee].y;
  while (las[xx][yy].v) {
    int ff = las[xx][yy].x;
    b[ss][ee][las[xx][yy].v - 1] = las[xx][yy].x;
    xx = xx - fx[ff][0];
    yy = yy - fx[ff][1];
  }
}
int main() {
  while (scanf("%d%d%d", &m, &n, &k) != EOF) {
    for (int i = 0; i < m; i++) {
      scanf("%s", a[i]);
    }
    scanf("%d%d%s%d%d", &st.x, &st.y, s + 1, &en.x, &en.y);
    memset(poi, -1, sizeof(poi));
    memset(c, 0, sizeof(c));
    poi[26].x = --st.x;
    poi[26].y = --st.y;
    poi[27].x = --en.x;
    poi[27].y = --en.y;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i][j] >= 'a' && a[i][j] <= 'z') {
          int ss = a[i][j] - 'a';
          poi[ss].x = i;
          poi[ss].y = j;
          a[i][j] = '1';
        }
      }
    }
    for (int i = 0; i < 28; i++) {
      if (poi[i].x == -1 || poi[i].y == -1) {
        continue;
      }
      for (int j = 0; j < 28; j++) {
        if (poi[j].x == -1 || poi[j].y == -1) {
          continue;
        }
        if (i == j) {
          continue;
        }
        getlength(i, j);
      }
    }
    s[0] = 'a' + 26;
    int sn = strlen(s);
    s[sn++] = 'a' + 27;
    int ansx = st.x, ansy = st.y;
    bool flag = false;
    for (int i = 1; i <= sn; i++) {
      int ss = s[i - 1] - 'a';
      int ee = s[i] - 'a';
      for (int j = 0; j < c[ss][ee]; j++) {
        if (k < a[ansx][ansy] - '0') {
          flag = true;
          break;
        } else {
          k -= a[ansx][ansy] - '0';
          ansx = ansx + fx[b[ss][ee][j]][0];
          ansy = ansy + fx[b[ss][ee][j]][1];
        }
      }
      if (flag) {
        break;
      }
    }
    printf("%d %d\n", ansx + 1, ansy + 1);
  }
  return 0;
}
