/*
TASK:tre
LANG:C++
*/

#include<iostream>
#include<queue>

class situation
{
public:
    int x, y;
    int time, cost;
    
    situation(){};
    situation(int Ax, int Ay, int Atime, int Acost){x=Ax; y=Ay; time=Atime; cost=Acost; }
};

int N, K, L, D;
int a[10000][100];

void read()
{
     std::cin>>N>>K>>L>>D;
     for(int i=0;i<=D-1;i++)
     {
         for(int j=0;j<=L-1;j++)
             std::cin>>a[i][j];
     }
}

int bfs(int l)
{
    int best=0;
    std::queue<situation> q;
    situation temp(l, 0, 0, a[0][l]);
    q.push(temp);
    
//    system("pause");
    while(!q.empty())
    {
        temp=q.front();
        q.pop();
//        std::cout<<"x="<<temp.x<<" y="<<temp.y<<" cost="<<temp.cost<<" time="<<temp.time<<std::endl;
        if(temp.time==K-1)
        {
            if(temp.cost>best)
                best=temp.cost;
//            std::cout<<std::endl;
//            std::cout<<"best="<<best<<std::endl;
//            std::cout<<temp.x<<' '<<temp.y<<' '<<temp.cost<<' '<<temp.time<<std::endl;
//            std::cout<<std::endl;
            continue;
        }
        if(temp.time>K-1)
            continue;
        
        for(int i=1;i<=L - temp.x - 1;i++)
        {
            situation t(temp.x+i, 0, temp.time+1, temp.cost+a[0][i]);
            q.push(t);
        }
        
        int p;
        int c=0;
        bool fl=false;
        for(p=1;p<=D- temp.y -1;p++)
        {
            c+=a[temp.y+p][temp.x];
            if(a[temp.y+p][temp.x]>0 && c>0)
                break;
            if(temp.time+p>=K)
            {
                fl=true;
                break;
            }
        }
        if(fl)
            continue;
        situation t(temp.x, temp.y+p, temp.time + p, temp.cost + c);
        q.push(t);
    }
    return best;
}

int main()
{
    read();
    int ans=0;
    for(int i=0;i<=L-1;i++)
    {
        int t=bfs(i);
        if(ans<t)
        {
            ans=t;
//            std::cout<<"ans="<<ans<<std::endl;
        }
    }
    std::cout<<ans<<std::endl;
//    system("pause");
    return 0;
}
