#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int N = 2007;
char tab[N][N];
int odl[N][N];
bool odw[N][N];
int skad[N][N];
int n, k;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%s", tab[i] + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int wyn = 1e9;
      if (i != 1) wyn = min(wyn, odl[i - 1][j]);
      if (j != 1) wyn = min(wyn, odl[i][j - 1]);
      if (i == 1 && j == 1) wyn = 0;
      if (tab[i][j] != 'a') wyn++;
      odl[i][j] = wyn;
    }
  }
  if (odl[n][n] <= k) {
    for (int i = 1; i < 2 * n; ++i) printf("a");
    printf("\n");
    return 0;
  }
  int maxl = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (odl[i][j] <= k) maxl = max(maxl, i + j);
    }
  }
  vector<pair<int, int>> q;
  bool spc = 0;
  if (maxl == 0) {
    maxl = 2;
    spc = 1;
    q.push_back({1, 1});
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (odl[i][j] <= k && i + j == maxl) {
        q.push_back({i, j});
      }
    }
  }
  for (int it = maxl - 1; it < 2 * n - 1; ++it) {
    char mini = 'z' + 1;
    for (auto u : q) {
      if (u.first + 1 <= n) mini = min(mini, tab[u.first + 1][u.second]);
      if (u.second + 1 <= n) mini = min(mini, tab[u.first][u.second + 1]);
    }
    vector<pair<int, int>> nq;
    for (auto u : q) {
      if (u.first + 1 <= n) {
        if (tab[u.first + 1][u.second] == mini) {
          skad[u.first + 1][u.second] = 1;
          if (!odw[u.first + 1][u.second]) {
            nq.emplace_back(u.first + 1, u.second);
          }
          odw[u.first + 1][u.second] = 1;
        }
      }
      if (u.second + 1 <= n) {
        if (tab[u.first][u.second + 1] == mini) {
          skad[u.first][u.second + 1] = 2;
          if (!odw[u.first][u.second + 1]) {
            nq.emplace_back(u.first, u.second + 1);
          }
          odw[u.first][u.second + 1] = 1;
        }
      }
    }
    q.swap(nq);
  }
  int i = n;
  int j = n;
  vector<char> res;
  while (i + j > maxl) {
    res.push_back(tab[i][j]);
    if (skad[i][j] == 1)
      i--;
    else
      j--;
  }
  if (!spc) {
    for (int it = 0; it < maxl - 1; ++it) printf("a");
  } else
    printf("%c", tab[1][1]);
  reverse(res.begin(), res.end());
  for (char c : res) printf("%c", c);
  printf("\n");
  return 0;
}
