#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int n, m, k, sx, sy, tx, ty;
int d[MAXN * MAXN], p[MAXN * MAXN];
int a[50][50];
int w[MAXN][MAXN];
int px[50], py[50];
char s[MAXN][MAXN];
char str[MAXN * MAXN];
vector<int> ed[MAXN * MAXN], cs[MAXN * MAXN];
const int fx[] = {0, 1, 0, -1}, fy[] = {1, 0, -1, 0};
set<pair<int, int> > dp;
void dfs(int x, int y, int v, int sum = 0) {
  if (s[x][y] >= 'a' && s[x][y] <= 'z' && s[x][y] - 'a' != v) {
    a[s[x][y] - 'a'][v] = a[v][s[x][y] - 'a'] = sum;
    return;
  }
  w[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int xx = x + fx[i], yy = y + fy[i];
    if (xx < 0 || yy < 0 || xx >= n || yy >= m || w[xx][yy] || s[xx][yy] == '#')
      continue;
    dfs(xx, yy, v, (isdigit(s[x][y]) ? (sum + s[x][y] - '0') : (sum + 1)));
  }
}
int ax, ay;
void get(int x, int y, int v, int sum, int st, int prevsum = 0) {
  if (s[x][y] >= 'a' && s[x][y] <= 'z' && s[x][y] - 'a' == v) {
    printf("%d %d\n", ax + 1, ay + 1);
    return;
  }
  if (s[x][y] >= 'a' && s[x][y] <= 'z' && s[x][y] != st) return;
  w[x][y] = 1;
  if ((prevsum > 0 && sum < 0) || sum == 0) ax = x, ay = y;
  for (int i = 0; i < 4; i++) {
    int xx = x + fx[i], yy = y + fy[i];
    if (xx < 0 || yy < 0 || xx >= n || yy >= m || w[xx][yy] || s[xx][yy] == '#')
      continue;
    get(xx, yy, v, (isdigit(s[xx][yy])) ? (sum - s[xx][yy] + '0') : (sum - 1),
        st, sum);
  }
}
int dijekstra(int s, int t) {
  for (int i = 0; i < n * m; i++) d[i] = 1000000000;
  d[s] = 0;
  dp.clear();
  for (int i = 0; i < n * m; i++) dp.insert(make_pair(d[i], i));
  for (; dp.size();) {
    int u = dp.begin()->second;
    dp.erase(dp.begin());
    for (int i = 0; i < ed[u].size(); i++)
      if (d[ed[u][i]] > d[u] + cs[u][i]) {
        dp.erase(dp.find(make_pair(d[ed[u][i]], ed[u][i])));
        d[ed[u][i]] = d[u] + cs[u][i];
        p[ed[u][i]] = u;
        dp.insert(make_pair(d[ed[u][i]], ed[u][i]));
      }
  }
  return d[t];
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  scanf("%d%d%s%d%d", &sx, &sy, str, &tx, &ty);
  sx--;
  sy--;
  tx--;
  ty--;
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < 26; j++) a[i][j] = (i == j) ? 0 : 1000000000;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] >= 'a' && s[i][j] <= 'z' && !w[i][j]) {
        px[s[i][j] - 'a'] = i;
        py[s[i][j] - 'a'] = j;
        dfs(i, j, s[i][j] - 'a');
      }
  for (int x = 0; x < n; x++)
    for (int y = 0; y < m; y++) {
      for (int i = 0; i < 4; i++) {
        int xx = x + fx[i], yy = y + fy[i];
        if (xx < 0 || yy < 0 || xx >= n || yy >= m || s[xx][yy] == '#')
          continue;
        ed[x * m + y].push_back(xx * m + yy);
        if (isdigit(s[x][y]))
          cs[x * m + y].push_back(s[x][y] - '0');
        else
          cs[x * m + y].push_back(1);
      }
    }
  int tot = dijekstra(sx * m + sy, px[str[0] - 'a'] * m + py[str[0] - 'a']);
  if (tot >= k) {
    int goal = d[px[str[0] - 'a'] * m + py[str[0] - 'a']] - (tot - k);
    int v = px[str[0] - 'a'] * m + py[str[0] - 'a'];
    while (d[v] != goal) v = p[v];
    printf("%d %d\n", v / m + 1, v % m + 1);
    return 0;
  }
  for (int i = 0; str[i + 1]; i++) {
    tot += a[str[i] - 'a'][str[i + 1] - 'a'];
    if (tot >= k) {
      memset(w, 0, sizeof(w));
      get(px[str[i + 1] - 'a'], py[str[i + 1] - 'a'], str[i] - 'a', tot - k,
          str[i + 1]);
      return 0;
    }
  }
  tot += dijekstra(tx * m + ty, px[str[strlen(str) - 1] - 'a'] * m +
                                    py[str[strlen(str) - 1] - 'a']);
  if (tot >= k) {
    int goal =
        d[px[str[strlen(str) - 1] - 'a'] * m + py[str[strlen(str) - 1] - 'a']] -
        (tot - k);
    int v = px[str[strlen(str) - 1] - 'a'] * m + py[str[strlen(str) - 1] - 'a'];
    while (d[v] != goal) v = p[v];
    printf("%d %d\n", v / m + 1, v % m + 1);
    return 0;
  }
  printf("%d %d\n", tx + 1, ty + 1);
  return 0;
}
