Problem: You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to complete the path fastest.

The track's map is represented by a rectangle n × m in size divided into squares. Each square is marked with a lowercase Latin letter (which means the type of the plot), with the exception of the starting square (it is marked with a capital Latin letters S) and the terminating square (it is marked with a capital Latin letter T). The time of movement from one square to another is equal to 1 minute. The time of movement within the cell can be neglected. We can move from the cell only to side-adjacent ones, but it is forbidden to go beyond the map edges. Also the following restriction is imposed on the path: it is not allowed to visit more than k different types of squares (squares of one type can be visited an infinite number of times). Squares marked with S and T have no type, so they are not counted. But S must be visited exactly once — at the very beginning, and T must be visited exactly once — at the very end.

Your task is to find the path from the square S to the square T that takes minimum time. Among all shortest paths you should choose the lexicographically minimal one. When comparing paths you should lexicographically represent them as a sequence of characters, that is, of plot types.

Input

The first input line contains three integers n, m and k (1 ≤ n, m ≤ 50, n·m ≥ 2, 1 ≤ k ≤ 4). Then n lines contain the map. Each line has the length of exactly m characters and consists of lowercase Latin letters and characters S and T. It is guaranteed that the map contains exactly one character S and exactly one character T.

Pretest 12 is one of the maximal tests for this problem.

Output

If there is a path that satisfies the condition, print it as a sequence of letters — the plot types. Otherwise, print "-1" (without quotes). You shouldn't print the character S in the beginning and T in the end.

Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted.

Examples

Input

5 3 2
Sba
ccc
aac
ccc
abT


Output

bcccc


Input

3 4 1
Sxyy
yxxx
yyyT


Output

xxxx


Input

1 3 3
TyS


Output

y


Input

1 4 1
SxyT


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 51, MAX2 = 26;
char mm[MAX][MAX];
int tm[MAX][MAX];
int n, m, k;
struct node {
  int st;
  int con[MAX2];
  int rev[MAX2];
  node(int a = 0) : st(a) {
    memset(con, -1, sizeof(con));
    memset(rev, -1, sizeof(rev));
  }
};
node stt[17905];
int stn;
int si, sj, ti, tj;
int dist[MAX - 1][MAX - 1][17905];
const int M1 = 10000000, M2 = 100000, M3 = 100;
struct nn {
  int x, y, id;
  nn(int a = 0, int b = 0, int c = 0) : x(a), y(b), id(c) {}
  void print() {
    printf("%d %d %d %s\n", x, y, id,
           bitset<20>(stt[id].st).to_string().data());
  }
};
int as(nn h) { return h.x * M1 + h.y * M2 + h.id; }
nn de(int st) { return {st / M1, st / M2 % M3, st % M2}; }
int dir[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
inline bool ic(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m; }
vector<pair<int, int> > adj[MAX][MAX];
unordered_map<int, int> mbs;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", mm[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mm[i][j] == 'S')
        si = i, sj = j;
      else if (mm[i][j] == 'T')
        ti = i, tj = j;
      else
        tm[i][j] = mm[i][j] - 'a';
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int d = 0; d < 4; d++) {
        int i1 = i + dir[d][0], j1 = j + dir[d][1];
        if (ic(i1, j1)) {
          adj[i][j].push_back({i1, j1});
        }
      }
    }
  }
  stn = 0;
  for (int i = 0; i < (1 << MAX2); i++) {
    int bs = __builtin_popcount(i);
    if (bs <= k) {
      stt[stn] = {i};
      mbs[i] = stn++;
    }
  }
  for (int i = 0; i < stn; i++) {
    int st = stt[i].st;
    for (int j = 0; j < MAX2; j++) {
      int sn = st | (1 << j);
      int num = __builtin_popcount(sn);
      if (num <= k) stt[i].con[j] = mbs[sn];
    }
    for (int j = 0; j < MAX2; j++) {
      if (st & (1 << j)) {
        int st1 = st & ~(1 << j);
        stt[i].rev[j] = mbs[st1];
      }
    }
  }
  memset(dist, -1, sizeof(dist));
  queue<int> Q;
  dist[ti][tj][0] = 0;
  Q.push(as({ti, tj, 0}));
  bool find = 0;
  while (!Q.empty()) {
    int cur1 = Q.front();
    nn cur = de(cur1);
    Q.pop();
    int curst = cur.id;
    int x = cur.x, y = cur.y;
    for (int i = 0; i < adj[x][y].size(); i++) {
      auto &ele = adj[x][y][i];
      int x1 = ele.first, y1 = ele.second;
      if (x1 == ti && y1 == tj) continue;
      int hst;
      if (x1 == si && y1 == sj) {
        hst = curst;
        if (dist[x1][y1][hst] == -1) {
          dist[x1][y1][hst] = dist[x][y][curst] + 1;
          find = 1;
        }
      } else {
        hst = stt[curst].con[tm[x1][y1]];
        if (hst != -1) {
          if (dist[x1][y1][hst] == -1) {
            dist[x1][y1][hst] = dist[x][y][curst] + 1;
            Q.push(as({x1, y1, hst}));
          }
        }
      }
    }
  }
  if (!find)
    printf("-1\n");
  else {
    int ml = INT_MAX;
    string ans;
    for (int i = 0; i < stn; i++) {
      if (dist[si][sj][i] != -1) ml = min(ml, dist[si][sj][i]);
    }
    unordered_set<int> prev;
    for (int i = 0; i < stn; i++) {
      if (dist[si][sj][i] == ml) prev.insert(as({si, sj, i}));
    }
    while (ml > 1) {
      int mz = INT_MAX;
      unordered_set<int> news;
      for (int ele : prev) {
        nn cur = de(ele);
        int x = cur.x, y = cur.y;
        int st, st2;
        st = cur.id;
        for (int d = 0; d < 4; d++) {
          int x1 = x + dir[d][0], y1 = y + dir[d][1];
          if (ic(x1, y1)) {
            if (dist[x1][y1][st] == ml - 1) mz = min(mz, tm[x1][y1]);
            if (!(x == si && y == sj)) {
              st2 = stt[st].rev[tm[x][y]];
              if (dist[x1][y1][st2] == ml - 1) mz = min(mz, tm[x1][y1]);
            }
          }
        }
      }
      for (int ele : prev) {
        nn cur = de(ele);
        int x = cur.x, y = cur.y;
        int st, st2;
        st = cur.id;
        for (int d = 0; d < 4; d++) {
          int x1 = x + dir[d][0], y1 = y + dir[d][1];
          if (ic(x1, y1)) {
            if (dist[x1][y1][st] == ml - 1)
              if (tm[x1][y1] == mz) news.insert(as({x1, y1, st}));
            if (!(x == si && y == sj)) {
              st2 = stt[st].rev[tm[x][y]];
              if (dist[x1][y1][st2] == ml - 1 && tm[x1][y1] == mz)
                news.insert(as({x1, y1, st2}));
            }
          }
        }
      }
      ans.push_back('a' + mz);
      prev = move(news);
      ml--;
    }
    printf("%s\n", ans.data());
  }
  return 0;
}