#include <bits/stdc++.h>
using namespace std;
ifstream  fi("matran.inp");
ofstream f1("matranb.out");
ofstream f2("maxdong.out");
long int m,n,i,j,m1,n1,tong=0,a[10000][10000],tongmax=-10000,vt1,vt2,md;

void maxdong(long int a[][10000])
{
    for(i=1;i<=m;i++)
        {md=a[i][0];
            for(j=1;j<=n;j++)
    {
       md=max(md,a[i][j]);
    }
    f2<<md<<" ";
        }
        return;
}
long long duyet(long int i, long int j,long int m1,long int n1)
{
    int i1,j1;
    long long tong=0;
        for(i1=i;i1<=i+m1-1;i1++)
		    for(j1=j;j1<=j+n1-1;j1++)
            tong=tong+a[i1][j1];

   return tong;
}
int main()
{
    fi>>m>>n>>m1>>n1;
       for(i=1;i<=m;i++ )
        for(j=1;j<=n;j++)
       {
    fi>>a[i][j];
       }
       for(i=1;i<=m-m1+1;i++)
        for(j=1;j<=n-n1+1;j++)
       {
           tong=duyet(i,j,m1,n1);
           if(tong>tongmax)
           {
               tongmax=tong;
               vt1=i;
               vt2=j;
           }
       }
       for(i=vt1;i<vt1+m1;i++)
       {for(j=vt2;j<vt2+n1;j++){
       f1<<a[i][j]<<" ";}
       f1<<endl;}
       maxdong(a);
    return 0;
}
