#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <unordered_set>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <stack>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define hashmap unordered_map
#define hashset unordered_set
#define pb push_back
#define ff first
#define ss second
#define en "\n"

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void __print(int x) { cerr << x; }
void __print(ll x) { cerr << x; }
void __print(ull x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(ld x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const string &x) { cerr << '"' << x << '"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

#ifdef LOCAL
#define debug(...) \
{ \
        cerr << "[" << #__VA_ARGS__ << "] = ["; \
        _print(__VA_ARGS__); \
}
#else
#define debug(...)
#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rnd(ll l, ll r)
{
        return uniform_int_distribution<ll>(l, r)(rng);
}

template<typename T, typename V>
void __print(const pair<T, V> &x);

template<typename T>
void __print(const T &x);

template<typename T, size_t N>
void __print(const array<T, N> &x);

template<typename... T>
void __print(const tuple<T...> &x);

template<class T>
bool maximize(T &a, const T &b)
{
        if(a < b)
        {
                a = b;

                return true;
        }

        return false;
}

template<class T>
bool minimize(T &a, const T &b)
{
        if(a > b)
        {
                a = b;

                return true;
        }

        return false;
}

template<typename T, typename V>
void __print(const pair<T, V> &x)
{
        cerr << '{';
        __print(x.ff);
        cerr << ", ";
        __print(x.ss);
        cerr << '}';
}

template<typename T>
void __print(const T &x)
{
        int f = 0;
        cerr << '{';
        for(auto &i : x) cerr << (f++ ? ", " : ""), __print(i);
        cerr << "}";
}

template<typename T, size_t N>
void __print(const array<T, N> &x)
{
        cerr << '{';
        int f = 0;
        for(auto &i : x) cerr << (f++ ? ", " : ""), __print(i);
        cerr << '}';
}

template<typename... T>
void __print(const tuple<T...> &x)
{
        cerr << '(';
        apply([&](const auto&... args)
        {
                int f = 0;
                ((cerr << (f++ ? ", " : ""), __print(args)), ...);
        }, x);
        cerr << ')';
}

void _print()
{
        cerr << "]" << en;
}

template<typename T, typename... V>
void _print(T t, V... v)
{
        __print(t);
        if(sizeof...(v)) cerr << ", ";
        _print(v...);
}

namespace brute_force
{
        void progress()
        {

        }
}

int m, n, h, w;
vector<vector<int>> a;

namespace accepted_solution
{
        void solve()
        {
                vector<vector<int>> cnt(m - h + 2, vector<int>(n - w + 2, 0));
                vector<vector<int>> prefix(m + 1, vector<int>(n + 1, 0));
                // for(int i = 1 ; i <= m ; i++)
                // {
                //         for(int j = 1 ; j <= n ; j++)
                //         {
                //                 for(int v = 0 ; v <= 100 ; v++)
                //                 {
                //                         prefix[v][i][j] = prefix[v][i - 1][j] + prefix[v][i][j - 1] - prefix[v][i - 1][j - 1] + (a[i][j] == v);
                //                 }
                //         }
                // }

                int need = (h * w + 1) / 2;
                int ans = inf;
                // for(int i = h ; i <= m ; i++)
                // {
                //         for(int j = w ; j <= n ; j++)
                //         {
                //                 int x1 = i - h + 1, y1 = j - w + 1;
                //                 int sum = 0;

                //                 for(int v = 0 ; v <= 100 ; v++)
                //                 {
                //                         sum += prefix[v][i][j] - prefix[v][x1 - 1][j] - prefix[v][i][y1 - 1] + prefix[v][x1 - 1][y1 - 1];

                //                         if(sum >= need)
                //                         {
                //                                 minimize(ans, v);
                //                                 break;
                //                         }
                //                 }
                //         }
                // }
                for(int v = 0 ; v <= 100 ; v++)
                {
                        for(int i = 1 ; i <= m ; i++)
                        {
                                for(int j =1  ; j <= n ; j++)
                                {
                                        prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + (a[i][j] == v);
                                }
                        }

                        for(int i = h ; i <= m ; i++)
                        {
                                for(int j = w ; j <= n ; j++)
                                {
                                        int x1 = i - h + 1, y1 = j - w + 1;
                                        cnt[x1][y1] += prefix[i][j] - prefix[x1 - 1][j] - prefix[i][y1 - 1] + prefix[x1 - 1][y1 - 1];

                                        if(cnt[x1][y1] >= need) minimize(ans, v);
                                }
                        }
                }

                cout << ans;
        }
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);

        #define task "VUONHOA"
        if(fopen(task ".inp", "r"))
        {
                freopen(task ".inp", "r", stdin);
                freopen(task ".out", "w", stdout);
        }

        cin >> m >> n >> h >> w;
        a.assign(m + 1, vector<int>(n+ 1, 0));
        for(int i = 1 ; i <= m ; i++)
        {
                for(int j = 1 ; j <= n ; j++)
                {
                        cin >> a[i][j];
                }
        }

        accepted_solution::solve();

        return 0;
}

/*
Compile in terminal: 
g++ -std=c++17 -O2 -Wall -Wextra -Wshadow -Wconversion main.cpp -o main.exe
main.exe

Debugging:
g++ -std=c++17 -O0 -g -DLOCAL main.cpp -o main
*/