#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e3 + 5;
const int M = 1e6 + 5;
char s[N][N];
int dp[N][N];
bool vis[N][N];
int n, k, cnt = -1;
char ans[M];
int main() {
  scanf("%d%d", &n, &k);
  k = min(k, 2 * n - 1);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  memset(dp, 63, sizeof dp);
  if (s[1][1] == 'a')
    dp[1][1] = 0;
  else
    dp[1][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (dp[i][j] <= k) s[i][j] = 'a';
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i + 1][j] != 'a'));
      dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j + 1] != 'a'));
    }
  }
  ans[++cnt] = s[1][1];
  vis[1][2] = 1, vis[2][1] = 1;
  for (int sum = 3; sum <= n + n; sum++) {
    char c = 'z';
    for (int i = 1; i <= n; i++) {
      int j = sum - i;
      if (j >= 1 && j <= n && vis[i][j] == 1) c = min(c, s[i][j]);
    }
    for (int i = 1; i <= n; i++) {
      int j = sum - i;
      if (j >= 1 && j <= n && s[i][j] == c && vis[i][j] == 1)
        vis[i + 1][j] = 1, vis[i][j + 1] = 1;
    }
    ans[++cnt] = c;
  }
  printf("%s\n", ans);
}
