#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=85,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; int n,m,k,t,c[N][N],d[N][N]; ll dis[N][N][N*4]; bool vis[N][N][N*4]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> m >> k >> t; if(t>=n+m-2){ cout << "0\n"; return 0; } for(int i=0; i> x >> y; x--,y--; cin >> c[x][y] >> d[x][y]; } for(int i=0; i>; priority_queue,greater> pq; dis[0][0][N*2+t]=0,pq.push({0,{0,0,N*2+t}}); while(!pq.empty()){ auto [_,arr]=pq.top(); pq.pop(); auto [x,y,cur]=arr; if(vis[x][y][cur]) continue; //cout << x << ' ' << y << ' ' << cur << endl; vis[x][y][cur]=1; if(cur-(n-1-x)-(m-1-y)>=N*2){ cout << dis[x][y][cur] << "\n"; return 0; } if(cur>0){ for(int i=0; i<4; ++i){ int nx=x+dx[i],ny=y+dy[i]; if(nx>=0&&nx=0&&ny0){ int ncur=min(cur+c[x][y]-1,N*2+(n+m-1)); if(dis[x][y][cur]+d[x][y]