#include <bits/stdc++.h>
using namespace std;
long long a[1010][1010];
long long n, m;
long long k, p;
long long f[1010], g[1010];
long long sum1[1000010], sum2[1000010];
map<long long, long long> mp1, mp2;
int main() {
  cin >> n >> m >> k >> p;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) scanf("%d", a[i] + j);
  }
  for (long long i = 1; i <= n; ++i) {
    f[i] = 0;
    for (long long j = 1; j <= m; ++j) f[i] += a[i][j];
    mp1[-f[i]]++;
  }
  for (long long j = 1; j <= m; ++j) {
    g[j] = 0;
    for (long long i = 1; i <= n; ++i) g[j] += a[i][j];
    mp2[-g[j]]++;
  }
  sum1[0] = sum2[0] = 0;
  for (long long i = 1; i <= k; ++i) {
    sum1[i] = sum1[i - 1] - mp1.begin()->first;
    sum2[i] = sum2[i - 1] - mp2.begin()->first;
    mp1[mp1.begin()->first + m * p]++;
    if (mp1.begin()->second > 1)
      mp1[mp1.begin()->first]--;
    else
      mp1.erase(mp1.begin());
    mp2[mp2.begin()->first + n * p]++;
    if (mp2.begin()->second > 1)
      mp2[mp2.begin()->first]--;
    else
      mp2.erase(mp2.begin());
  }
  long long ans;
  ans = -1000000000000000000LL;
  for (long long i = 0; i <= k; ++i) {
    ans = max(ans, sum1[i] + sum2[k - i] - i * (k - i) * p);
  }
  cout << ans << endl;
  return 0;
}
