#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T qmin(const T &a, const T &b) {     return a < b ? a : b;   }   template <typename T>   inline T qmax(const T &a, const T &b) {     return a > b ? a : b;   }   template <typename T>   inline void getmin(T &a, const T &b) {     if (a > b) a = b;   }   template <typename T>   inline void getmax(T &a, const T &b) {     if (a < b) a = b;   }   inline void fileio(string s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   const int inf = 1e9 + 7;   const int N = 51, M = 2953;   const int go[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};   char g[N][N];   int tp[N][N];   map<int, int> id;   int mask[M], cnt;   int dis[N][N][M];   bool vis[N][N][M], can[N][N][M];   int ans[N][N][M];   vector<pair<pair<int, int>, int> > to[N][N][M];   int n, m, k, sti, stj, edi, edj;   inline void bfs() {     static queue<pair<pair<int, int>, int> > q;     static int st, ed;     dis[sti][stj][1] = 1;     q.push(make_pair(make_pair(sti, stj), 1));     while (!q.empty()) {       pair<pair<int, int>, int> p = q.front();       q.pop();       int i = p.first.first, j = p.first.second, comb = mask[p.second];       if (dis[i][j][p.second] == dis[edi][edj][1]) break;       comb |= (~tp[i][j] ? 1 << tp[i][j] : 0);       for (register int d = 0; d < (4); ++d) {         int ni = i + go[d][0], nj = j + go[d][1];         if (ni < 1 || ni > n || nj < 1 || nj > m || (ni == sti && nj == stj))           continue;         int ncomb = comb;         if (~tp[ni][nj]) {           ncomb &= ~(1 << tp[ni][nj]);           if (__builtin_popcount(ncomb) >= k) continue;         } else {           ncomb = 0;         }         int cid = id[ncomb];         if (dis[ni][nj][cid]) {           if (dis[ni][nj][cid] == dis[i][j][p.second] + 1)             to[i][j][p.second].push_back(make_pair(make_pair(ni, nj), cid));           continue;         }         dis[ni][nj][cid] = dis[i][j][p.second] + 1;         q.push(make_pair(make_pair(ni, nj), cid));         to[i][j][p.second].push_back(make_pair(make_pair(ni, nj), cid));       }     }   }   inline bool cmp(const pair<pair<int, int>, int> &a,                   const pair<pair<int, int>, int> &b) {     pair<int, int> p = a.first, q = b.first;     if (g[p.first][p.second] != g[q.first][q.second])       return g[p.first][p.second] < g[q.first][q.second];     if (p.first == edi && p.second == edj) return false;     return cmp(to[p.first][p.second][a.second][ans[p.first][p.second][a.second]],                to[q.first][q.second][b.second][ans[q.first][q.second][b.second]]);   }   inline void dfs(int i, int j, int k) {     if (vis[i][j][k]) return;     vis[i][j][k] = true;     if (i == edi && j == edj) {       can[i][j][k] = true;       return;     }     vector<pair<int, int> > nxt;     for (register int d = 0; d < (to[i][j][k].size()); ++d) {       pair<pair<int, int>, int> p = to[i][j][k][d];       int ni = p.first.first, nj = p.first.second, nk = p.second;       nxt.push_back(make_pair(tp[ni][nj], d));     }     sort(nxt.begin(), nxt.end());     for (int id1 = 0, id2; id1 < nxt.size(); id1 = id2) {       int bst = -1;       for (id2 = id1; id2 < nxt.size() && nxt[id2].first == nxt[id1].first;            ++id2) {         pair<pair<int, int>, int> p = to[i][j][k][nxt[id2].second];         dfs(p.first.first, p.first.second, p.second);         if (can[p.first.first][p.first.second][p.second]) {           if (bst == -1 || cmp(p, to[i][j][k][bst])) bst = nxt[id2].second;         }       }       if (~bst) {         can[i][j][k] = true;         ans[i][j][k] = bst;         return;       }     }   }   inline void getans(pair<pair<int, int>, int> a) {     pair<int, int> p = a.first;     if (p.first == edi && p.second == edj) return;     if (p.first != sti || p.second != stj) putchar(g[p.first][p.second]);     getans(to[p.first][p.second][a.second][ans[p.first][p.second][a.second]]);   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (register int i = (1); i <= (n); ++i) {       scanf( %s , g[i] + 1);       for (register int j = (1); j <= (m); ++j) {         if (g[i][j] ==  S ) {           tp[i][j] = -1;           sti = i, stj = j;         } else if (g[i][j] ==  T ) {           tp[i][j] = -1;           edi = i, edj = j;         } else {           tp[i][j] = g[i][j] -  a ;         }       }     }     id[0] = ++cnt;     mask[cnt] = 0;     for (register int i = (1); i <= (k - 1); ++i) {       for (int comb = (1 << i) - 1, x, y; comb < (1 << 26);            x = comb & -comb, y = comb + x, comb = ((comb & ~y) / x >> 1) | y) {         id[comb] = ++cnt;         mask[cnt] = comb;       }     }     bfs();     if (!dis[edi][edj][1]) return puts( -1 ), 0;     dfs(sti, stj, 1);     getans(make_pair(make_pair(sti, stj), 1));     puts(  );     return 0;   }