#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32777216")
using namespace std;
const long double pi = acos(-1.0);
const int INF = 1000000000;
string s[107];
int n, m, k;
pair<int, int> junc[27];
int d[107][107][30];
pair<int, int> p[107][107][30];
int ok(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) return -1;
  if (s[x][y] == '#') return -1;
  if (s[x][y] >= 'a' && s[x][y] <= 'z') return 1;
  return int(s[x][y] - '0');
}
bool j(int x, int y) { return (s[x][y] >= 'a' && s[x][y] <= 'z'); }
int main() {
  cin >> n >> m >> k;
  for (int(i) = (0); (i) < (n); ++(i)) cin >> s[i];
  for (int(i) = (0); (i) < (26); ++(i)) junc[i] = make_pair(-1, -1);
  for (int(i) = (0); (i) < (n); ++(i))
    for (int(j) = (0); (j) < (m); ++(j))
      if (s[i][j] >= 'a' && s[i][j] <= 'z')
        junc[s[i][j] - 'a'] = make_pair(i, j);
  int Sx, Sy, Ex, Ey;
  string S;
  cin >> Sx >> Sy >> S >> Ex >> Ey;
  Sx--;
  Sy--;
  Ex--;
  Ey--;
  junc[26] = make_pair(Ex, Ey);
  for (int(i) = (0); (i) < (107); ++(i))
    for (int(j) = (0); (j) < (107); ++(j))
      for (int(t) = (0); (t) < (30); ++(t)) d[i][j][t] = INF;
  for (int(i) = (0); (i) < (27); ++(i))
    if (junc[i] != make_pair(-1, -1)) {
      d[junc[i].first][junc[i].second][i] = 0;
      priority_queue<pair<int, pair<int, int> > > q;
      q.push(make_pair(0, make_pair(junc[i].first, junc[i].second)));
      while (!q.empty()) {
        int vx = q.top().second.first, cur_d = -q.top().first;
        int vy = q.top().second.second;
        q.pop();
        if (cur_d > d[vx][vy][i]) continue;
        if (ok(vx - 1, vy) != -1) {
          int len = ok(vx, vy);
          if (d[vx][vy][i] + len < d[vx - 1][vy][i]) {
            d[vx - 1][vy][i] = d[vx][vy][i] + len;
            p[vx - 1][vy][i] = make_pair(vx, vy);
            if (!j(vx - 1, vy))
              q.push(make_pair(-d[vx - 1][vy][i], make_pair(vx - 1, vy)));
          }
        }
        if (ok(vx + 1, vy) != -1) {
          int len = ok(vx, vy);
          if (d[vx][vy][i] + len < d[vx + 1][vy][i]) {
            d[vx + 1][vy][i] = d[vx][vy][i] + len;
            p[vx + 1][vy][i] = make_pair(vx, vy);
            if (!j(vx + 1, vy))
              q.push(make_pair(-d[vx + 1][vy][i], make_pair(vx + 1, vy)));
          }
        }
        if (ok(vx, vy - 1) != -1) {
          int len = ok(vx, vy);
          if (d[vx][vy][i] + len < d[vx][vy - 1][i]) {
            d[vx][vy - 1][i] = d[vx][vy][i] + len;
            p[vx][vy - 1][i] = make_pair(vx, vy);
            if (!j(vx, vy - 1))
              q.push(make_pair(-d[vx][vy - 1][i], make_pair(vx, vy - 1)));
          }
        }
        if (ok(vx, vy + 1) != -1) {
          int len = ok(vx, vy);
          if (d[vx][vy][i] + len < d[vx][vy + 1][i]) {
            d[vx][vy + 1][i] = d[vx][vy][i] + len;
            p[vx][vy + 1][i] = make_pair(vx, vy);
            if (!j(vx, vy + 1))
              q.push(make_pair(-d[vx][vy + 1][i], make_pair(vx, vy + 1)));
          }
        }
      }
    }
  int first = Sx;
  int second = Sy;
  int t = 0;
  S += ('a' + 26);
  for (int(i) = (0); (i) < (S.size()); ++(i)) {
    while (make_pair(first, second) != junc[S[i] - 'a']) {
      if (ok(first, second) + t > k) {
        cout << first + 1 << ' ' << second + 1 << endl;
        return 0;
      }
      t += ok(first, second);
      int XX = first, YY = second;
      first = p[XX][YY][S[i] - 'a'].first;
      second = p[XX][YY][S[i] - 'a'].second;
    }
  }
  cout << first + 1 << ' ' << second + 1 << endl;
  return 0;
}
