#include <bits/stdc++.h>   using namespace std;   char s[500][500];   int di[4] = {-1, 1, 0, 0};   int dj[4] = {0, 0, -1, 1};   typedef int int2d[500][500];   int2d p[26];   int2d d;   struct Pos {     int r, c;     Pos(int r = 0, int c = 0) : r(r), c(c) {}     void init(int r, int c) {       this->r = r;       this->c = c;     }     bool operator<(const Pos& p) const {       int d1 = d[r][c], d2 = d[p.r][p.c];       return d1 < d2 || d1 == d2 && (r < p.r || r == p.r && c < p.c);     }   } wh[27];   int n, m;   bool isDigit(char c) { return c >=  0  && c <=  9 ; }   set<Pos> heap;   void calc(int i, int j, int2d& par) {     memset(d, 127, sizeof(d));     d[i][j] = 0;     heap.insert(Pos(i, j));     while (!heap.empty()) {       Pos p = *heap.begin();       heap.erase(heap.begin());       char ch = s[p.r][p.c];       if (!isDigit(ch) && ch != s[i][j]) {         continue;       }       int cost = (isDigit(ch) ? ch -  0  : 1) + d[p.r][p.c];       for (int dir = 0; dir < 4; dir++) {         int r = p.r + di[dir], c = p.c + dj[dir];         if (r >= 0 && c >= 0 && r < n && c < m && s[r][c] !=  # ) {           if (d[r][c] > cost) {             heap.erase(Pos(r, c));             d[r][c] = cost;             heap.insert(Pos(r, c));             par[r][c] = dir;           }         }       }     }   }   char sm[10000];   int main() {     int k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       scanf( %s , s[i]);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] >=  a  && s[i][j] <=  z ) {           wh[s[i][j] -  a ].init(i, j);           calc(i, j, p[s[i][j] -  a ]);         }       }     }     int r, c;     int r2, c2;     scanf( %d %d %s %d %d , &r, &c, sm, &r2, &c2);     r--, c--;     r2--, c2--;     calc(r2, c2, p[26]);     int len = strlen(sm);     for (int i = 0; i < len && k;) {       char ch = s[r][c];       if (ch == sm[i]) {         i++;         continue;       }       int cost = (isDigit(ch) ? ch -  0  : 1);       int dir = p[sm[i] -  a ][r][c];       if (cost > k) {         k = 0;         break;       }       k -= cost;       r -= di[dir];       c -= dj[dir];     }     while (k > 0 && (r != r2 || c != c2)) {       char ch = s[r][c];       int cost = (isDigit(ch) ? ch -  0  : 1);       if (cost > k) {         k = cost;         exit(1);         break;       }       k -= cost;       int dir = p[26][r][c];       r -= di[dir];       c -= dj[dir];     }     printf( %d %d n , r + 1, c + 1);     return 0;   }   