#include <bits/stdc++.h>
using namespace std;
struct Point {
  int first, second;
  Point(){};
  Point(int a, int b) { first = a, second = b; }
  friend bool operator<(Point a, Point b) {
    return a.first == b.first ? a.second < b.second : a.first < b.first;
  }
};
char a[110][110];
char ctrl[1010];
Point p[1010], s, t;
Point pre[27][110][110];
int dist[27][110][110];
int n, m, k;
priority_queue<pair<int, Point>, vector<pair<int, Point> >,
               greater<pair<int, Point> > >
    seq;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
void run(int c, Point s) {
  for (int i = s.first + 1; i <= n; i++)
    dist[c][i][s.second] = dist[c][i - 1][s.second] + a[i - 1][s.second],
    pre[c][i][s.second] = Point(i - 1, s.second);
  for (int i = s.first - 1; i >= 1; i--)
    dist[c][i][s.second] = dist[c][i + 1][s.second] + a[i + 1][s.second],
    pre[c][i][s.second] = Point(i + 1, s.second);
  for (int j = s.second + 1; j <= m; j++)
    dist[c][s.first][j] = dist[c][s.first][j - 1] + a[s.first][j - 1],
    pre[c][s.first][j] = Point(s.first, j - 1);
  for (int j = s.second - 1; j >= 1; j--)
    dist[c][s.first][j] = dist[c][s.first][j + 1] + a[s.first][j + 1],
    pre[c][s.first][j] = Point(s.first, j + 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (a[i][j] <= 'z' && a[i][j] >= 'a') {
        p[a[i][j] - 'a'] = Point(i, j);
        a[i][j] = 1;
      } else if (a[i][j] != '#')
        a[i][j] -= '0';
    }
  memset(dist, 127, sizeof dist);
  for (int i = 0; i < 26; i++)
    if (p[i].first > 0) {
      dist[i][p[i].first][p[i].second] = 0;
      run(i, p[i]);
    }
  scanf("%d%d%s%d%d", &s.first, &s.second, ctrl + 1, &t.first, &t.second);
  dist[26][s.first][s.second] = 0, run(26, s);
  ctrl[0] = 26;
  int len = strlen(ctrl);
  for (int i = 0; i < len - 1; i++) {
    ctrl[i + 1] -= 'a';
    if (k <= dist[ctrl[i]][p[ctrl[i + 1]].first][p[ctrl[i + 1]].second]) {
      Point now = p[ctrl[i + 1]];
      while (dist[ctrl[i]][now.first][now.second] > k)
        now = pre[ctrl[i]][now.first][now.second];
      printf("%d %d\n", now.first, now.second);
      return 0;
    } else
      k -= dist[ctrl[i]][p[ctrl[i + 1]].first][p[ctrl[i + 1]].second];
  }
  if (k <= dist[ctrl[len - 1]][t.first][t.second]) {
    Point now = t;
    while (dist[ctrl[len - 1]][now.first][now.second] > k)
      now = pre[ctrl[len - 1]][now.first][now.second];
    printf("%d %d\n", now.first, now.second);
    return 0;
  }
  printf("%d %d\n", t.first, t.second);
  return 0;
}
