#include <bits/stdc++.h>
using namespace std;
const int DBG = 0, INF = int(1e9);
const int MAXN = 100;
vector<string> M;
int n, m;
pair<int, int> pos[300];
int getValue(char c) {
  if (c >= '1' && c <= '9') return c - '0';
  if (c >= 'a' && c <= 'z') return 1;
  return 0;
}
int getCost(pair<int, int> a, pair<int, int> b, int len) {
  int res = 0;
  if (a.first == b.first) {
    if (a.second < b.second) {
      for (int _b = (b.second - 1), i = (a.second); i <= _b; ++i) {
        res += getValue(M[a.first][i]);
        if (res >= len) {
          if (res == len)
            cout << a.first + 1 << " " << i + 2 << endl;
          else
            cout << a.first + 1 << " " << i + 1 << endl;
          exit(0);
        }
      }
    } else {
      for (int _b = (b.second + 1), i = (a.second); i >= _b; --i) {
        res += getValue(M[a.first][i]);
        if (res >= len) {
          if (res == len)
            cout << a.first + 1 << " " << (i - 1) + 1 << endl;
          else
            cout << a.first + 1 << " " << (i) + 1 << endl;
          exit(0);
        }
      }
    }
  } else {
    assert(a.second == b.second);
    if (a.first < b.first) {
      for (int _b = (b.first - 1), i = (a.first); i <= _b; ++i) {
        res += getValue(M[i][a.second]);
        if (res >= len) {
          if (res == len)
            cout << i + 2 << " " << a.second + 1 << endl;
          else
            cout << i + 1 << " " << a.second + 1 << endl;
          exit(0);
        }
      }
    } else {
      for (int _b = (b.first + 1), i = (a.first); i >= _b; --i) {
        res += getValue(M[i][a.second]);
        if (res >= len) {
          if (res == len)
            cout << (i - 1) + 1 << " " << a.second + 1 << endl;
          else
            cout << (i) + 1 << " " << a.second + 1 << endl;
          exit(0);
        }
      }
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.setf(ios::fixed);
  int k;
  cin >> m >> n >> k;
  M.resize(m);
  for (int _n = (m), i = 0; i < _n; ++i) cin >> M[i];
  pair<int, int> start, fin;
  string path;
  cin >> start.first >> start.second >> path >> fin.first >> fin.second;
  start.first--;
  start.second--;
  fin.first--;
  fin.second--;
  for (int _n = (m), i = 0; i < _n; ++i)
    for (int _n = (n), j = 0; j < _n; ++j)
      if (M[i][j] >= 'a' && M[i][j] <= 'z') pos[M[i][j]] = make_pair(i, j);
  int len = k;
  pair<int, int> curPos = start;
  for (__typeof(path.begin()) it = path.begin(); it != path.end(); ++it) {
    pair<int, int> nextPos = pos[*it];
    int cost = getCost(curPos, nextPos, len);
    len -= cost;
    curPos = nextPos;
  }
  pair<int, int> nextPos = fin;
  int cost = getCost(curPos, nextPos, len);
  cout << nextPos.first + 1 << " " << nextPos.second + 1 << endl;
  return 0;
}
