#include <bits/stdc++.h>
using namespace std;
int main() {
  string trash;
  int n, k;
  cin >> n >> k;
  getline(cin, trash);
  vector<vector<char> > field(n + 2, vector<char>(n + 2));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> field[i][j];
    }
    getline(cin, trash);
  }
  vector<vector<int> > dp(n + 2, vector<int>(n + 2, 1e9));
  dp[1][1] = field[1][1] == 'a' ? 0 : 1;
  int maximum = 2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j && i == 1) continue;
      dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + (field[i][j] == 'a' ? 0 : 1);
      if (dp[i][j] <= k && i + j > maximum) maximum = i + j;
    }
  }
  queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i + j == maximum && dp[i][j] <= k) {
        q.push(make_pair(i, j));
        field[i][j] = 'a';
      }
    }
  }
  string s(maximum - 1, 'a');
  s += string(2 * n - 1 - s.length(), 'z' + 1);
  vector<vector<bool> > m(n + 2, vector<bool>(n + 2));
  if (k == 0) {
    s[0] = field[1][1];
    q.push(make_pair(1, 1));
  }
  while (q.size() > 0) {
    pair<int, int> curNode = q.front();
    q.pop();
    int i = curNode.first;
    int j = curNode.second;
    if (s[i + j - 2] != field[i][j]) continue;
    if (i + 1 <= n && field[i + 1][j] <= s[i + j - 1]) {
      s[i + j - 1] = field[i + 1][j];
      if (m[i + 1][j] == false) {
        q.push(make_pair(i + 1, j));
        m[i + 1][j] = true;
      }
    }
    if (j + 1 <= n && field[i][j + 1] <= s[i + j - 1]) {
      s[i + j - 1] = field[i][j + 1];
      if (m[i][j + 1] == false) {
        q.push(make_pair(i, j + 1));
        m[i][j + 1] = true;
      }
    }
  }
  cout << s;
  return 0;
}
