#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, p;
int a[N][N];
int pre[N][N];
int getPre(int x, int y) { return x < 0 || y < 0 ? 0 : pre[x][y]; }
int main() {
scanf("%d %d %d", &n, &m, &p);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
scanf("%d", &a[i][j]);
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
pre[i][j] = getPre(i-1, j) + getPre(i, j-1) - getPre(i-1, j-1);
a[i][j] -= pre[i][j] - getPre(i-p, j) - getPre(i, j-p) + getPre(i-p, j-p);
if (a[i][j] < 0) return 0 * printf("TIDAK\n");
if ((i > n-p || j > m-p) && a[i][j] != 0) return 0 * printf("TIDAK\n");
pre[i][j] += a[i][j];
}
}
printf("YA\n");
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQgTiA9IDEwMDU7CgppbnQgbiwgbSwgcDsKaW50IGFbTl1bTl07CgppbnQgcHJlW05dW05dOwppbnQgZ2V0UHJlKGludCB4LCBpbnQgeSkgeyByZXR1cm4geCA8IDAgfHwgeSA8IDAgPyAwIDogcHJlW3hdW3ldOyB9CgppbnQgbWFpbigpIHsKICBzY2FuZigiJWQgJWQgJWQiLCAmbiwgJm0sICZwKTsKICBmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgZm9yIChpbnQgaiA9IDA7IGogPCBtOyArK2opIHsKICAgICAgc2NhbmYoIiVkIiwgJmFbaV1bal0pOwogICAgfQogIH0KCiAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgIGZvciAoaW50IGogPSAwOyBqIDwgbTsgKytqKSB7CiAgICAgIHByZVtpXVtqXSA9IGdldFByZShpLTEsIGopICsgZ2V0UHJlKGksIGotMSkgLSBnZXRQcmUoaS0xLCBqLTEpOwogICAgICBhW2ldW2pdIC09IHByZVtpXVtqXSAtIGdldFByZShpLXAsIGopIC0gZ2V0UHJlKGksIGotcCkgKyBnZXRQcmUoaS1wLCBqLXApOwoKICAgICAgaWYgKGFbaV1bal0gPCAwKSByZXR1cm4gMCAqIHByaW50ZigiVElEQUtcbiIpOwogICAgICBpZiAoKGkgPiBuLXAgfHwgaiA+IG0tcCkgJiYgYVtpXVtqXSAhPSAwKSByZXR1cm4gMCAqIHByaW50ZigiVElEQUtcbiIpOwoKICAgICAgcHJlW2ldW2pdICs9IGFbaV1bal07CiAgICB9CiAgfQoKICBwcmludGYoIllBXG4iKTsgCiAgcmV0dXJuIDA7Cn0K