#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const long double EPS = 1e-9;
const long double PI = fabs(atan2(0.0, -1.0));
int n, m, k;
char board[105][105];
int rs, cs;
char path[1005];
int re, ce;
void load() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", board[i]);
  scanf("%d%d", &rs, &cs);
  --rs, --cs;
  scanf("%s", path);
  scanf("%d%d", &re, &ce);
  --re, --ce;
}
const int dx[4] = {0, 1, -1, 0};
const int dy[4] = {1, 0, 0, -1};
inline bool good(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
inline bool isJunction(char c) { return 'a' <= c && c <= 'z'; }
inline int getCost(char c) {
  if ('1' <= c && c <= '9') return c - '0';
  if ('a' <= c && c <= 'z') return 1;
  throw 42;
}
pair<int, int> points[30];
vector<pair<int, int> > cpath;
int step = 0;
int cost = 0;
int was[1005][1005];
bool dfs(int x, int y, int xf, int yf, int k) {
  if (x == xf && y == yf) return true;
  if (isJunction(board[x][y])) k--;
  if (k < 0) return false;
  cpath.push_back(make_pair(x, y));
  was[x][y] = step;
  cost += getCost(board[x][y]);
  for (int t = 0; t < 4; t++) {
    int nx = x + dx[t];
    int ny = y + dy[t];
    if (!good(nx, ny) || board[nx][ny] == '#') continue;
    if (was[nx][ny] == step) continue;
    if (dfs(nx, ny, xf, yf, k)) return true;
  }
  cost -= getCost(board[x][y]);
  cpath.pop_back();
  return false;
}
void solve() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c = board[i][j];
      if ('a' <= c && c <= 'z') points[c - 'a'] = make_pair(i, j);
    }
  }
  points[26] = make_pair(rs, cs);
  points[27] = make_pair(re, ce);
  vector<int> way;
  way.push_back(26);
  for (int i = 0; path[i]; i++) way.push_back(path[i] - 'a');
  way.push_back(27);
  for (int i = 0; i < (int)way.size() - 1; i++) {
    int x1 = points[way[i]].first;
    int y1 = points[way[i]].second;
    int x2 = points[way[i + 1]].first;
    int y2 = points[way[i + 1]].second;
    cpath.resize(0);
    step++;
    cost = 0;
    dfs(x1, y1, x2, y2, isJunction(board[x1][y1]));
    if (k >= cost)
      k -= cost;
    else {
      for (int j = 0; j < (int)cpath.size(); j++) {
        int x = cpath[j].first;
        int y = cpath[j].second;
        int cres = getCost(board[x][y]);
        if (k >= cres)
          k -= cres;
        else {
          printf("%d %d\n", x + 1, y + 1);
          return;
        }
      }
      assert(false);
    }
  }
  printf("%d %d\n", re + 1, ce + 1);
}
int main() {
  load();
  solve();
  return 0;
}
