#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using namespace std;
int n, m;
string s[2100];
int dp[2100][2100];
pair<int, int> f[2100][2100];
int main() {
  ios::sync_with_stdio(0);
  int k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) f[i][j] = {-1, -1};
  int mx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      if (j) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      if (s[i][j] == 'a') dp[i][j]++;
      if (i + j + 1 - dp[i][j] <= k) mx = max(mx, (int)i + j + 1);
    }
  }
  int m = n;
  if (mx == n + m - 1) {
    for (int i = 0; i < mx; i++) cout << "a";
    return 0;
  }
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i + j + 1 - dp[i][j] <= k) {
        if (i + j + 1 == mx) v.push_back({i, j});
      }
    }
  }
  string pas = "";
  if (v.size() == 0) {
    pas += s[0][0];
    v.push_back({0, 0});
  }
  while (mx--) pas += "a";
  while (v.size()) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    int mn = 10000;
    for (auto k : v) {
      int x = k.first;
      int y = k.second;
      if (x < n - 1) mn = min(mn, (int)s[x + 1][y]);
      if (y < n - 1) mn = min(mn, (int)s[x][y + 1]);
      if (x == n - 1 && y == n - 1) {
        cout << pas;
        return 0;
      }
    }
    vector<pair<int, int> > t;
    for (auto k : v) {
      int x = k.first;
      int y = k.second;
      if (x < n - 1) {
        if (mn == s[x + 1][y]) t.push_back({x + 1, y});
      }
      if (y < n - 1) {
        if (mn == s[x][y + 1]) t.push_back({x, y + 1});
      }
    }
    pas += (char)mn;
    v = t;
  }
}
