#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, h;
  scanf("%lld %lld %lld", &n, &m, &h);
  long long int f[m], l[n];
  long long int t;
  long long int v[n][m];
  for (long long int i = 0; i < m; i++) scanf("%lld", &f[i]);
  for (long long int i = 0; i < n; i++) scanf("%lld", &l[n - 1 - i]);
  for (long long int i = n - 1; i >= 0; i--) {
    for (long long int j = 0; j < m; j++) {
      scanf("%lld", &t);
      if (t == 0)
        v[i][j] = 0;
      else {
        v[i][j] = min(f[j], l[i]);
      }
    }
  }
  for (long long int i = n - 1; i >= 0; i--) {
    for (long long int j = 0; j < m; j++) printf("%lld ", v[i][j]);
    printf("\n");
  }
}
