#include"bits/stdc++.h"
using namespace std;

vector<string> split(const string & s, char c=' ') {
   vector<string> v; stringstream ss(s); string x;
   while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
   stringstream s; s << "[";
   for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
   s << arr[n - 1] << "]";
   return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; } 
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
   cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
   __evars_out_var(a);
   cerr << "; ";
   __evars(++it, args...);
}
template<typename T>
void maxa(T &a,T b){
  if(a<b) a=b;
}
template<typename T>
void mina(T &a,T b){
  if(a>b) a=b;
}

#define int long long
const int inf=1e18;
#define F first
#define S second
#define Z(c) (int)(c).size()
#define pii pair<int,int>
const int mod=1e9+7;
const int N=3e5+15;
  
  int n,k,tt;
  int a[808][808];
  int c[808][808];

  bool chk(int m){

     for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
           if(a[i][j]<=m) c[i][j]=1;
           else c[i][j]=0;
           c[i][j]+=c[i-1][j]+c[i][j-1]-c[i-1][j-1];
        }
     }

     for(int i=1;i<=n;++i){
         for(int j=1;j<=n;++j){
             if(i+k-1<=n&&j+k-1<=n){
                  int sm=c[i+k-1][j+k-1]+c[i-1][j-1]-c[i+k-1][j-1]-c[i-1][j+k-1];
                  // EVARS(i,j,sm);
                  if(sm>=tt) return true;
             }
         }
     }

     return false;
  }
  void boomer(){

      cin>>n>>k;
      tt=(k*k)/2;
      tt=k*k-tt;

      for(int i=1;i<=n;++i){
          for(int j=1;j<=n;++j){
             cin>>a[i][j];
          }
      }

      int lw=0,hg=1e9,mid;
      
      // EVARS(chk(3));

      while(lw<hg){ 
         mid=(lw+hg)/2;

         if(chk(mid))
          hg=mid;
         else
          lw=mid+1;
      }

      cout<<hg;
  }  
  signed main()
  { 
  ios_base::sync_with_stdio(0); cin.tie(0); 
 
  int tc=1;

  // cin>>tc; 
  for(int i=1;i<=tc;++i)
  { 
  // cout<<"Case #"<<i<<": ";
  boomer();
  if(i<tc)
  cout<<"\n";
  }

  return 0; 
  }
#include <bits/stdc++.h>
using namespace std;

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define im(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	//vector<vector<int>> h(100, vector<int>());
	vector<vector<vector<double>>> a(101, vector<vector<double>>(101, vector<double>(101)));
	int b, c, d;
	cin >> b >> c >> d;
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			for (int k = 0; k < 101; k++) {
				a[i][j][k] = 0;
			}
		}
	}
	a[b][c][d] = 1;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			for (int k = 0; k < 100; k++) {
				if (a[i][j][k] == 0) {
					continue;
				}
				double pom = (double) i / (double) (i + j + k);
				a[i + 1][j][k] = max(a[i + 1][j][k], 0.0) + pom * a[i][j][k];
				pom = (double) j / (double) (i + j + k);
				a[i][j + 1][k] = max(a[i][j + 1][k], 0.0) + pom * a[i][j][k];
				pom = (double) k / (double) (i + j + k);
				a[i][j][k + 1] = max(0.0, a[i][j][k + 1]) + pom * a[i][j][k];
			}
		}
	}
	double res = 0;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			res = res + a[100][i][j] * ((100 - b) + (i - c) + (j - d));
		}
	}
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			res = res + a[i][100][j] * ((100 - c) + (i - b) + (j - d));
		}
	}
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			res = res + a[i][j][100] * ((100 - d) + (i - b) + (j - c));
		}
	}
	//debug() << a;
	cout << setprecision(10);
	cout << res << nl;
}
