#include <bits/stdc++.h>
using namespace std;
map<char, pair<int, int> > m1;
pair<int, int> navigate(pair<int, int> p1, char in) {
  pair<int, int> target = m1[in];
  if (p1.first == target.first && p1.second > target.second) {
    return make_pair(p1.first, --p1.second);
  } else if (p1.first == target.first && p1.second < target.second) {
    return make_pair(p1.first, ++p1.second);
  } else if (p1.first > target.first && p1.second == target.second) {
    return make_pair(--p1.first, p1.second);
  } else {
    return make_pair(++p1.first, p1.second);
  }
}
bool epoint(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first == p2.first && p1.second == p2.second) return true;
  return false;
}
int timeSpend(char in) {
  if (isalpha(in)) return 1;
  return in - '0';
}
int main() {
  int m, n, k;
  pair<int, int> st, end;
  string s;
  char mat[101][101];
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char temp;
      cin >> temp;
      if (isalpha(temp)) m1[temp] = make_pair(i, j);
      mat[i][j] = temp;
    }
  int x, y, x1, y1;
  cin >> x >> y >> s >> x1 >> y1;
  st = make_pair(x, y);
  end = make_pair(x1, y1);
  m1['!'] = end;
  int pointer = 0;
  for (int pointer = 0; pointer < s.size(); pointer++)
    while (!epoint(st, m1[s[pointer]])) {
      k -= timeSpend(mat[st.first][st.second]);
      if (k < 0) goto end;
      st = navigate(st, s[pointer]);
      if (k == 0) goto end;
    }
  while (!epoint(st, end)) {
    k -= timeSpend(mat[st.first][st.second]);
    if (k < 0) goto end;
    st = navigate(st, '!');
    if (k == 0) goto end;
  }
end:
  cout << st.first << " " << st.second << endl;
  return 0;
}
