#include <bits/stdc++.h>
using namespace std;
const long long N = 2e4 + 7;
const long long INF = 1e13 + 239;
long long dp[N];
long long ndp[N];
void rec(vector<long long> a, long long n, long long k) {
  auto sum = [&](long long l, long long r) {
    long long ans = 0;
    r = min(r, n);
    for (long long i = l; i < r; i++) ans += a[i];
    return ans;
  };
  for (long long l = 0; l + k <= n; l++) {
    dp[l] += sum(l, l + k);
  }
  vector<long long> pmax(n + 1, -INF);
  for (long long i = 0; i < n; i++) {
    pmax[i + 1] = max(pmax[i], dp[i]);
  }
  vector<long long> smax(n + 1, -INF);
  for (long long i = n - 1; i >= 0; i--) {
    smax[i] = max(smax[i + 1], dp[i]);
  }
  for (long long l = 0; l + k <= n; l++) {
    ndp[l] = -1;
    long long ous = sum(l, l + k);
    if (l - k >= 0) {
      ndp[l] = max(ndp[l], pmax[l - k] + ous);
    }
    if (l + k <= n) {
      ndp[l] = max(ndp[l], smax[l + k] + ous);
    }
    for (long long i = max((long long)0, l - k); i < min(n, l + k); i++) {
      long long il = max(i, l);
      long long ir = min(i + k, l + k);
      long long ins = sum(il, ir);
      ndp[l] = max(ndp[l], dp[i] + ous - ins);
    }
  }
}
void ref() {
  for (long long i = 0; i < N; i++) {
    dp[i] = ndp[i];
    ndp[i] = -INF;
  }
}
void init(vector<long long> a, long long n, long long k) {
  fill(dp, dp + N, -INF);
  auto sum = [&](long long l, long long r) {
    long long ans = 0;
    for (long long i = l; i < r; i++) ans += a[i];
    return ans;
  };
  for (long long l = 0; l + k <= n; l++) {
    dp[l] = sum(l, l + k);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long q, n, k;
  cin >> q >> n >> k;
  vector<long long> a(n);
  for (auto &t : a) {
    cin >> t;
  }
  init(a, n, k);
  q--;
  while (q--) {
    for (auto &t : a) {
      cin >> t;
    }
    rec(a, n, k);
    ref();
  }
  cout << *max_element(dp, dp + N) << endl;
}
