#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
int n, m, k;
char mat[maxn][maxn];
int jx[maxn];
int jy[maxn];
string s;
int iv;
int jv;
void getjah(int x, int y, int fx, int fy) {
  iv = 0;
  jv = 0;
  if (fx > x) {
    iv = 1;
    jv = 0;
  }
  if (fy > y) {
    iv = 0;
    jv = 1;
  }
  if (fx < x) {
    iv = -1;
    jv = 0;
  }
  if (fy < y) {
    iv = 0;
    jv = -1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  for (int it = 0; it < t; ++it) {
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        cin >> mat[i][j];
        if (isalpha(mat[i][j])) {
          jx[mat[i][j] - 'a'] = i;
          jy[mat[i][j] - 'a'] = j;
        }
      }
    int cx, cy;
    cin >> cx >> cy;
    int tx, ty;
    cin >> s;
    cin >> tx >> ty;
    cx--;
    cy--;
    tx--;
    ty--;
    int now = 0;
    while (k > 0) {
      if (isalpha(mat[cx][cy])) {
        k--;
        now++;
      } else
        k -= mat[cx][cy] - '0';
      if (k < 0) break;
      if (now < (int)(s).size())
        getjah(cx, cy, jx[s[now] - 'a'], jy[s[now] - 'a']);
      else {
        if (cx == tx && cy == ty) break;
        getjah(cx, cy, tx, ty);
      }
      cx += iv;
      cy += jv;
    }
    cout << cx + 1 << " " << cy + 1 << endl;
  }
  return 0;
}
