#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int N, M, K, ID[30], D[30][30], st, ed, buc[10005];
char S[105][105], str[1005];
int len;
struct node {
  int v, next, k;
} E[40005];
int Elen, tim[10005], head[10005], pre[10005], dis[10005], vis[10005];
void add(int u, int v, int k) {
  ++Elen, E[Elen].v = v, E[Elen].next = head[u], head[u] = Elen, E[Elen].k = k;
}
inline int id(int x, int y) { return (x - 1) * M + y; }
inline void output(int id) {
  int x = (id - 1) / M + 1;
  printf("%d %d\n", x, id - (x - 1) * M);
}
struct data {
  int u, d;
  data(int u = 0, int d = 0) : u(u), d(d) {}
  bool operator<(const data& t) const { return d > t.d; }
};
priority_queue<data> Q;
void dij(int S) {
  for (int i = 1; i <= N * M; ++i) dis[i] = INF, vis[i] = 0, pre[i] = 0;
  dis[S] = 0, Q.push(data(S, 0));
  while (!Q.empty()) {
    int u = Q.top().u;
    Q.pop();
    if (u != S && buc[u]) continue;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = E[i].next)
      if (dis[u] + E[i].k < dis[E[i].v]) {
        dis[E[i].v] = dis[u] + E[i].k, pre[E[i].v] = u,
        Q.push(data(E[i].v, dis[E[i].v]));
      }
  }
}
int arr[10005], arrlen;
void path(int S, int T, int K) {
  dij(S);
  arrlen = 0;
  int u = T;
  while (u != S) {
    arr[++arrlen] = u, u = pre[u];
  }
  arr[++arrlen] = S;
  while (1) {
    int u = arr[arrlen];
    if (K < tim[u]) {
      output(u);
      return;
    } else
      K -= tim[u];
    --arrlen;
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; ++i) scanf("%s", S[i] + 1);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j)
      if (S[i][j] != '#') {
        if ('a' <= S[i][j] && S[i][j] <= 'z') {
          if (i > 1 && S[i - 1][j] != '#') add(id(i, j), id(i - 1, j), 1);
          if (i < N && S[i + 1][j] != '#') add(id(i, j), id(i + 1, j), 1);
          if (j > 1 && S[i][j - 1] != '#') add(id(i, j), id(i, j - 1), 1);
          if (j < M && S[i][j + 1] != '#') add(id(i, j), id(i, j + 1), 1);
          ID[S[i][j] - 'a'] = id(i, j), buc[id(i, j)] = 1, tim[id(i, j)] = 1;
        } else {
          if (i > 1 && S[i - 1][j] != '#')
            add(id(i, j), id(i - 1, j), S[i][j] - '0');
          if (i < N && S[i + 1][j] != '#')
            add(id(i, j), id(i + 1, j), S[i][j] - '0');
          if (j > 1 && S[i][j - 1] != '#')
            add(id(i, j), id(i, j - 1), S[i][j] - '0');
          if (j < M && S[i][j + 1] != '#')
            add(id(i, j), id(i, j + 1), S[i][j] - '0');
          tim[id(i, j)] = S[i][j] - '0';
        }
      }
  int x, y;
  scanf("%d%d", &x, &y), ID[26] = id(x, y);
  scanf("%s%d%d", str + 1, &x, &y), len = strlen(str + 1), ID[27] = id(x, y);
  for (int i = 0; i <= 27; ++i)
    if (ID[i]) {
      dij(ID[i]);
      for (int j = 0; j <= 27; ++j)
        if (ID[j]) {
          D[i][j] = dis[ID[j]];
        }
    }
  int u = 26;
  for (int i = 1; i <= len; ++i) {
    if (K >= D[u][str[i] - 'a'])
      K -= D[u][str[i] - 'a'];
    else {
      path(ID[u], ID[str[i] - 'a'], K);
      return 0;
    }
    u = str[i] - 'a';
  }
  if (K >= D[u][27])
    output(ID[27]);
  else
    path(ID[u], ID[27], K);
  return 0;
}
