#include <bits/stdc++.h>
using namespace std;
int f[(1 << 16) + 1][16][16], n, m, i, j, k, tt, a[16][10001], lg[16][16],
    lc[16][16], kq;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      lg[i][j] = abs(a[i][1] - a[j][1]);
      for (k = 2; k <= m; k++)
        lg[i][j] = min(lg[i][j], abs(a[i][k] - abs(a[j][k])));
      lc[i][j] = round(2e9) + 1;
      for (k = 2; k <= m; k++)
        lc[i][j] = min(lc[i][j], abs(a[i][k] - abs(a[j][k - 1])));
    }
  if (n == 1) {
    cout << lc[0][0] << '\n';
    return 0;
  }
  for (tt = 1; tt < (1 << n); tt++)
    for (i = 0; i < n; i++)
      if ((tt >> i) & 1) {
        if (tt == (1 << i))
          f[tt][i][i] = round(2e9) + 1;
        else
          for (j = 0; j < n; j++)
            if (((tt >> j) & 1) && j != i) {
              for (k = 0; k < n; k++)
                if (((tt >> k) & 1) && j != k) {
                  int x = min(f[tt - (1 << j)][i][k], lg[j][k]);
                  if (tt == (1 << n) - 1) x = min(x, lc[i][j]);
                  f[tt][i][j] = max(f[tt][i][j], x);
                  if (tt == (1 << n) - 1) kq = max(kq, f[tt][i][j]);
                }
              if (tt == (1 << n) - 1) kq = max(kq, f[tt][i][j]);
            }
      }
  cout << kq;
}
