/*
TASK:tre
LANG:C++
*/
#include<stdio.h>
#include<vector>
#include<algorithm>
typedef struct treasure
{
 int price;
 int time;
};
using namespace std;
bool cmp(treasure a1,treasure a2);
int main()
{
 int map[2][10004]={0},i,j,k,l,d,n,tmp,time=0,f,max=0;
 treasure otg[10002];
 scanf("%d%d%d%d",&n,&k,&l,&d);
 for(i=1,f=1;i<=d;i++,f*=-1)
 {
  for(j=0;j<l;j++)
  {
   scanf("%d",&tmp);
   if(f==1)map[0][j]=tmp+map[1][j];
    else map[1][j]=tmp+map[0][j];
   if(map[0][j]>otg[j].price&&f==1){otg[j].price=map[0][j];otg[j].time=i;}
    else if(map[1][j]>otg[j].price&&f==-1){otg[j].price=map[1][j];otg[j].time=i;}
  }
 }
 sort(otg,otg+n-1,cmp);
 for(max=0,i=0;i<n;i++)
 {
  for(j=i,tmp=0,time=0;j<n;j++)
  {
   if(time+otg[j].time<=k){tmp+=otg[j].price;time+=otg[j].time;}
  }
  if(tmp>max)max=tmp;
 }
 printf("%d\n",max);
 return 0;
}
bool cmp(treasure a1,treasure a2)
{
 if(a1.time<a2.time)return true;
 else if(a1.time==a2.time&&a1.price>a2.price)return true;
 else return false;
}
