#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long large = 2000000000000000000LL;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > g(n, vector<int>(n, 0));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      g[i][j] = (int)(s[j] - 'a');
    }
  }
  vector<vector<int> > dis(n, vector<int>(n, 1000000000));
  dis[0][0] = min(1, g[0][0]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i + 1 < n)
        dis[i + 1][j] = min(dis[i + 1][j], dis[i][j] + min(1, g[i + 1][j]));
      if (j + 1 < n)
        dis[i][j + 1] = min(dis[i][j + 1], dis[i][j] + min(1, g[i][j + 1]));
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (dis[i][j] <= k) g[i][j] = 0;
  }
  vector<vector<int> > can(n, vector<int>(n, 0));
  can[0][0] = 1;
  for (int l = 1; l < 2 * n - 1; l++) {
    vector<int> reach(26, 0);
    for (int i = 0; i < n; i++) {
      int j = l - i;
      if (j >= 0 && j < n) {
        if (i - 1 >= 0 && can[i - 1][j]) reach[g[i][j]] = 1;
        if (j - 1 >= 0 && can[i][j - 1]) reach[g[i][j]] = 1;
      }
    }
    int c = -1;
    for (int i = 0; i < 26; i++)
      if (reach[i]) {
        c = i;
        break;
      }
    assert(c != -1);
    for (int i = 0; i < n; i++) {
      int j = l - i;
      if (j >= 0 && j < n) {
        if (i - 1 >= 0 && can[i - 1][j] && g[i][j] == c) can[i][j] = 1;
        if (j - 1 >= 0 && can[i][j - 1] && g[i][j] == c) can[i][j] = 1;
      }
    }
  }
  int r = n - 1, c = n - 1;
  vector<int> re(1, g[r][c]);
  for (int l = 1; l < 2 * n - 1; l++) {
    if (r - 1 >= 0 && can[r - 1][c]) {
      r--;
      re.push_back(g[r][c]);
    } else if (c - 1 >= 0 && can[r][c - 1]) {
      c--;
      re.push_back(g[r][c]);
    }
  }
  reverse(re.begin(), re.end());
  for (int i = 0; i < (int)re.size(); i++) cout << (char)('a' + re[i]);
  return 0;
}
