#include <bits/stdc++.h>
using namespace std;
void GO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
const long long INF = 1e9 + 7;
const long long mod = (1e9) + 7;
const int maxn = (int)2001;
const long double PI = acos(-1.0);
const long double eps = 0.000000001;
mt19937 rnd(time(0));
int dp[maxn][maxn];
void solve() {
  int n, k;
  cin >> n >> k;
  vector<string> a(n);
  for (auto &i : a) cin >> i;
  dp[0][0] = (a[0][0] != 'a');
  for (int i = 1; i < n; ++i) {
    dp[0][i] = dp[0][i - 1] + (a[0][i] != 'a');
    dp[i][0] = dp[i - 1][0] + (a[i][0] != 'a');
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + (a[i][j] != 'a');
    }
  }
  set<pair<int, int> > mas;
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (dp[i][j] > k) continue;
      if (i + j > mx) mas.clear(), mx = i + j;
      if (i + j == mx) mas.insert({i, j});
    }
  }
  string ans;
  if (!int(mas.size())) {
    ans += a[0][0];
    mas.insert({0, 0});
  } else
    for (int i = 0; i < mas.begin()->first + mas.begin()->second + 1; ++i)
      ans += 'a';
  while (int(mas.size())) {
    set<pair<int, int> > mas2;
    char best = '~';
    for (auto &c : mas) {
      int i = c.first, j = c.second;
      if (i + 1 < n) {
        if (a[i + 1][j] < best) best = a[i + 1][j], mas2.clear();
        if (a[i + 1][j] == best) mas2.insert({i + 1, j});
      }
      if (j + 1 < n) {
        if (a[i][j + 1] < best) best = a[i][j + 1], mas2.clear();
        if (a[i][j + 1] == best) mas2.insert({i, j + 1});
      }
    }
    if (best != '~') ans += best;
    mas = mas2;
  }
  cout << ans;
}
signed main() {
  GO();
  int Q = 1;
  while (Q--) {
    solve();
  }
}
