#include <bits/stdc++.h>
using namespace std;
char a[110][110];
int t[110][110];
int n, m, k;
int x, y, ex, ey;
int pos[30][2];
string op;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] >= 'a') {
        pos[a[i][j] - 'a'][0] = i;
        pos[a[i][j] - 'a'][1] = j;
        t[i][j] = 1;
      } else if (a[i][j] != '#')
        t[i][j] = a[i][j] - '0';
    }
  }
  cin >> x >> y >> op >> ex >> ey;
  x--;
  y--;
  ex--;
  ey--;
  op += (char)('z' + 1);
  pos[26][0] = ex;
  pos[26][1] = ey;
  for (int i = 0; i < op.length(); i++) {
    int px = pos[op[i] - 'a'][0];
    int py = pos[op[i] - 'a'][1];
    while (x != px || y != py) {
      k -= t[x][y];
      if (k < 0) {
        cout << x + 1 << ' ' << y + 1 << endl;
        return 0;
      }
      if (x < px)
        x++;
      else if (x > px)
        x--;
      else if (y < py)
        y++;
      else if (y > py)
        y--;
    }
  }
  cout << x + 1 << ' ' << y + 1 << endl;
  return 0;
}
