#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 5007;
int n, k, f[maxn][maxn], mx;
char s[maxn][maxn];
vector<pair<int, int> > v;
bool vis[maxn][maxn];
void bfs() {
  vector<int> path;
  memset(vis, 0, sizeof(vis));
  vector<pair<int, int> > nxt;
  int xxx = v[0].first, yyy = v[0].second;
  vector<pair<int, int> > nxt2;
  for (int i = 0; i < v.size(); ++i) {
    int X = v[i].first, Y = v[i].second;
    vis[X][Y] = 1;
    nxt.push_back(v[i]);
  }
  for (int i = 0; i < n * 2 - (xxx + yyy); i++) {
    int min_col = 0x3f3f3f3f;
    ;
    for (int j = 0; j < nxt.size(); j++) {
      int xx = nxt[j].first, yy = nxt[j].second;
      for (int k = 0; k <= 1; ++k) {
        int tx = (k & 1) ? xx + 1 : xx;
        int ty = !(k & 1) ? yy + 1 : yy;
        if (tx > n || ty > n) continue;
        min_col = min(min_col, s[tx][ty] - 'a');
      }
    }
    path.push_back(min_col);
    nxt2.clear();
    for (int j = 0; j < nxt.size(); j++) {
      int xx = nxt[j].first, yy = nxt[j].second;
      for (int k = 0; k <= 1; ++k) {
        int tx = (k & 1) ? xx + 1 : xx;
        int ty = !(k & 1) ? yy + 1 : yy;
        if (tx > n || ty > n) continue;
        if (!vis[tx][ty] && s[tx][ty] - 'a' == min_col) {
          vis[tx][ty] = 1;
          nxt2.push_back(make_pair(tx, ty));
        }
      }
    }
    nxt = nxt2;
  }
  for (int i = 1; i <= mx; i++) putchar('a');
  if (mx == -1) putchar(s[1][1]);
  for (int i = 0; i < path.size(); i++) {
    putchar(path[i] + 'a');
  }
}
int GG, id[maxn][maxn];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) s[i][0] = 'z' + 1;
  for (int i = 1; i <= n; i++) s[0][i] = s[n + 1][i] = 'z' + 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      id[i][j] = ++GG;
      f[i][j] = max(f[i - 1][j], f[i][j - 1]);
      if (s[i][j] == 'a') f[i][j]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int ned = i + j - f[i][j] - 1;
      if (ned <= k) {
        if (i + j > mx)
          v.clear(), v.push_back(make_pair(i, j)), mx = i + j;
        else if (i + j == mx)
          v.push_back(make_pair(i, j));
      }
    }
  }
  mx--;
  if (mx == -1) {
    v.push_back(make_pair(1, 1));
  }
  bfs();
  return 0;
}
