#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, b;
string s;
string arr[115];
int dirx[4] = {0, 0, 1, -1}, diry[4] = {1, -1, 0, 0};
struct dsf {
  int x, y;
} w[35];
int dis[35][35];
int sx, sy, tx, ty;
int pan(int x, int y) {
  if (arr[x][y] - '1' >= 0 && arr[x][y] - '9' <= 0) return arr[x][y] - '0';
  return 1;
}
int v[115][115], vis[115][115];
dsf q[100500];
dsf pre[115][115];
int spfa(int s, int t) {
  long long head, tail;
  memset(v, -1, sizeof(v));
  memset(vis, -1, sizeof(vis));
  memset(pre, -1, sizeof(pre));
  v[w[s].x][w[s].y] = 0;
  vis[w[s].x][w[s].y] = 1;
  head = 1;
  tail = 1;
  q[1].x = w[s].x;
  q[1].y = w[s].y;
  dsf now, nex;
  int a, fen;
  while (head <= tail) {
    now.x = q[head % 100005].x;
    now.y = q[head % 100005].y;
    if (arr[now.x][now.y] - 'a' >= 0 && arr[now.x][now.y] - 'z' <= 0 &&
        head != 1) {
      head++;
      continue;
    }
    for (a = 0; a <= 3; a++) {
      nex.x = now.x + dirx[a];
      nex.y = now.y + diry[a];
      if (nex.x >= 1 && nex.x <= n && nex.y >= 1 && nex.y <= m &&
          arr[nex.x][nex.y] != '#') {
        fen = pan(now.x, now.y);
        if (v[nex.x][nex.y] == -1 || v[nex.x][nex.y] > fen + v[now.x][now.y]) {
          v[nex.x][nex.y] = fen + v[now.x][now.y];
          pre[nex.x][nex.y].x = now.x;
          pre[nex.x][nex.y].y = now.y;
          if (vis[nex.x][nex.y] == -1) {
            vis[nex.x][nex.y] = 1;
            tail++;
            q[tail % 100005].x = nex.x;
            q[tail % 100005].y = nex.y;
            if (v[q[tail % 100005].x][q[tail % 100005].y] <
                v[q[(head + 1) % 100005].x][q[(head + 1) % 100005].y]) {
              swap(q[tail % 100005].x, q[(head + 1) % 100005].x);
              swap(q[tail % 100005].y, q[(head + 1) % 100005].y);
            }
          }
        }
      }
    }
    head++;
    vis[now.x][now.y] = -1;
  }
  for (a = 0; a <= 27; a++)
    if (w[a].x != 0 && w[a].y != 0) {
      dis[s][a] = v[w[a].x][w[a].y];
    }
  int x, y;
  x = w[t].x;
  y = w[t].y;
  if (k > v[x][y]) {
    k -= v[x][y];
    return 0;
  }
  while (true) {
    int cx, cy;
    if (v[x][y] > k) {
      cx = pre[x][y].x;
      cy = pre[x][y].y;
      x = cx;
      y = cy;
    } else {
      cout << x << ' ' << y << endl;
      break;
    }
  }
  k = 0;
  return 0;
}
int main() {
  memset(w, 0, sizeof(w));
  memset(dis, -1, sizeof(dis));
  cin >> n >> m >> k;
  for (a = 1; a <= n; a++) {
    cin >> arr[a];
    arr[a] = "." + arr[a];
  }
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      if (arr[a][b] - 'a' >= 0 && arr[a][b] - 'z' <= 0) {
        w[arr[a][b] - 'a'].x = a;
        w[arr[a][b] - 'a'].y = b;
      }
  cin >> sx >> sy >> s >> tx >> ty;
  s = s + "}";
  w[26].x = sx;
  w[26].y = sy;
  w[27].x = tx;
  w[27].y = ty;
  int shang = 26;
  for (int a = 0; a < s.size(); a++) {
    int xia = s[a] - 'a';
    if (dis[shang][xia] == -1)
      spfa(shang, xia);
    else {
      if (dis[shang][xia] < k)
        k -= dis[shang][xia];
      else
        spfa(shang, xia);
    }
    shang = xia;
    if (k == 0) break;
  }
  if (k != 0) cout << tx << ' ' << ty << endl;
}
