using namespace std; int main() {
int w, s;
cin >> w >> s;
int x, y;
cin >> x >> y;
vector<int>a(x * w + 1);
for (int i = 1;i < x * w + 1;i++) {
int a1;
cin >> a1;
a[i] = a1;
}
vector<int>b(s * x + 1);
for (int i = 1;i < s * x + 1;i++) {
int b1;
cin >> b1;
b[i] = b1;
}
for (int i = 0;i < w;i++) {
for (int j = 1;j <= x;j++) {
for (int l = 0;l < s;l++) {
a[j + i * x] = a[j + i * x] - b[j + l * s];
}
if (a[j + i * x] < y) {
a[j + i * x] = y;
}
cout << a[j + i * x];
if (j == x) {
cout << endl;
}
else {
cout << " ";
}
}
}
return 0;
}