#include <bits/stdc++.h>
using namespace std;
string grid[2010];
int freq[2010][2010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  const bool TEST = false && (n == 2000 && k == 485);
  for (int i = 1; i <= n; i++) {
    cin >> grid[i];
    grid[i] = "~" + grid[i] + "~";
  }
  grid[0] = grid[n + 1] = string(n + 2, '~');
  for (int i = 0; i < n + 2; i++) {
    cerr << grid[i] << endl;
  }
  for (int i = 2; i <= n; i++) {
    freq[i][0] = freq[0][i] = 1e9;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      freq[i][j] = min(freq[i - 1][j], freq[i][j - 1]) + (grid[i][j] != 'a');
    }
  }
  if (k >= freq[n][n]) {
    cout << string(2 * n - 1, 'a') << '\n';
    return 0;
  }
  vector<pair<int, int> > curr;
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (freq[i][j] == k) {
        if (mx < i + j - 1) {
          curr.clear();
          mx = i + j - 1;
        }
        if (mx == i + j - 1) {
          curr.emplace_back(i, j);
        }
      }
    }
  }
  string ans(mx, 'a');
  if (TEST) {
    cout << mx << '\n';
  }
  if (curr.empty()) {
    curr.emplace_back(1, 1);
    ans += grid[1][1];
  }
  while ((int)ans.size() < 2 * n - 1) {
    char small = '~';
    for (auto& p : curr) {
      small = min(
          {small, grid[p.first + 1][p.second], grid[p.first][p.second + 1]});
    }
    ans.push_back(small);
    vector<pair<int, int> > next;
    for (auto& p : curr) {
      if (grid[p.first][p.second + 1] == small) {
        next.emplace_back(p.first, p.second + 1);
      }
      if (grid[p.first + 1][p.second] == small) {
        next.emplace_back(p.first + 1, p.second);
      }
    }
    sort(next.begin(), next.end());
    next.resize(unique(next.begin(), next.end()) - next.begin());
    curr = next;
  }
  cout << ans << endl;
  return 0;
}
