#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
struct vertex {
  vertex* up[26];
  int r, c;
  int enter, exit;
};
struct cmp {
  bool operator()(vertex* a, vertex* b) {
    return a->enter > b->enter or a->enter == b->enter and a->exit > b->exit;
  }
};
vertex v[30][128 * 128];
char buf[128][128];
int num(char c) { return c >= '0' and c <= '9' ? c - '0' : 1; }
void build_tree(int x, int y, int id) {
  bool done[128 * 128] = {};
  for (int i = 128 * 128; i--;) {
    v[id][i].exit = num(buf[i / 128][i % 128]);
    v[id][i].enter = 1 << 30;
    v[id][i].r = i / 128;
    v[id][i].c = i % 128;
  }
  v[id][x * 128 + y].enter = 0, v[id][x * 128 + y].exit = num(buf[x][y]);
  v[id][x * 128 + y].up[0] = v[id] + x * 128 + y;
  for (int i = 128 * 128; i--;)
    for (int j = 23; j--;) v[id][i].up[j] = &v[id][i];
  priority_queue<vertex*, vector<vertex*>, cmp> todo;
  todo.push(v[id] + x * 128 + y);
  while (not todo.empty()) {
    vertex* c = todo.top();
    todo.pop();
    if (done[c - v[id]])
      continue;
    else
      done[c - v[id]] = true;
    static int dx[4] = {-1, 0, 1, 0};
    static int dy[4] = {0, -1, 0, 1};
    for (int u = 4; u--;) {
      int tr = c->r + dx[u];
      int tc = c->c + dy[u];
      int tm = c->exit;
      if (buf[tr][tc] != '#' and tm < v[id][tr * 128 + tc].enter) {
        v[id][tr * 128 + tc].enter = tm;
        v[id][tr * 128 + tc].exit = tm + num(buf[tr][tc]);
        v[id][tr * 128 + tc].up[0] = c;
        for (int j = 0; j < 23; j++) {
          v[id][tr * 128 + tc].up[j + 1] = v[id][tr * 128 + tc].up[j]->up[j];
        }
        if (buf[tr][tc] < 'a' or buf[tr][tc] > 'z' or
            buf[tr][tc] == buf[x][y]) {
          todo.push(v[id] + tr * 128 + tc);
        }
      }
    }
  }
}
void run() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> buf[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (buf[i][j] >= 'a' and buf[i][j] <= 'z') {
        build_tree(i, j, buf[i][j] - 'a');
      }
    }
  int id;
  int r, c;
  int x, y;
  string op;
  cin >> r >> c >> op >> x >> y;
  --r, --c, --x, --y;
  op += char('z' + 1);
  build_tree(x, y, 26);
  for (char ch : op) {
    int key = r * 128 + c;
    id = ch - 'a';
    vertex* on = &v[id][key];
    for (int q = 22; q--;) {
      int delta = (on->exit) - (on->up[q]->exit);
      if (delta <= k) {
        on = on->up[q];
        k -= delta;
      }
    }
    r = on->r;
    c = on->c;
  }
  cout << r + 1 << " " << c + 1 << endl;
}
