#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
const int d[2] = {1, 0};
bool vis[N][N];
char str[N];
int n, k;
int ans[N << 1];
int a[N][N];
struct node {
  int x, y, cnt, stp, tmp;
  node() {}
  node(int a, int b, int c, int d, int e) {
    x = a;
    y = b;
    cnt = c;
    stp = d;
    tmp = e;
  }
  bool operator>(const node &a) const {
    if (stp == a.stp && tmp == a.tmp) return cnt > a.cnt;
    if (stp == a.stp) return tmp > a.tmp;
    return stp > a.stp;
  }
};
priority_queue<node, vector<node>, greater<node> > q;
bool check(int cnt, int x, int y) {
  if (k - cnt > 0 && a[x][y] != 0) return 1;
  return 0;
}
void solve() {
  for (int i = 1; i <= 2 * n - 1; i++) ans[i] = -1;
  node u = node(1, 1, 0, 1, 0);
  if (check(0, 1, 1))
    u.cnt = 1, ans[1] = 0;
  else
    ans[1] = a[1][1];
  u.tmp = ans[1];
  q.push(u);
  while (!q.empty()) {
    node u = q.top();
    q.pop();
    if (ans[u.stp] != -1 && ans[u.stp] < u.tmp) continue;
    if (ans[u.stp] == -1) ans[u.stp] = u.tmp;
    for (int i = 0; i < 2; i++) {
      int tx = u.x + d[i];
      int ty = u.y + d[1 - i];
      if (tx > n || ty > n) continue;
      if (vis[tx][ty]) continue;
      vis[tx][ty] = 1;
      node v = node(tx, ty, u.cnt, u.stp + 1, 0);
      if (check(u.cnt, tx, ty))
        v.cnt++, v.tmp = 0;
      else
        v.tmp = a[tx][ty];
      q.push(v);
    }
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str + 1);
    for (int j = 1; j <= n; j++) a[i][j] = str[j] - 'a';
  }
  solve();
  for (int i = 1; i <= 2 * n - 1; i++) printf("%c", ans[i] + 'a');
  puts("");
  return 0;
}
