#include <bits/stdc++.h>
using namespace std;
long long int pi[1000], ai[1000];
long long int bsearch(long long int arr[], long long int x, long long int n) {
  long long int a = 0;
  long long int k;
  long long int b = n - 1;
  while (a <= b) {
    k = (a + b) / 2;
    if (arr[k] == x) {
    }
    if (arr[k] > x)
      b = k - 1;
    else
      a = k + 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, k = 0, m, n, f = 0, c = 0, f1 = 0, f2 = 0, c1 = 0, c2 = 0,
                      h;
  cin >> n >> m >> h;
  long long int ara[n][m], p[m], q[n];
  for (i = 0; i < m; i++) cin >> p[i];
  for (i = 0; i < n; i++) cin >> q[i];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> ara[i][j];
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (ara[i][j] == 1) {
        ara[i][j] = q[i];
      }
    }
  }
  for (i = 0; i < m; i++) {
    for (j = n - 1; j >= 0; j--) {
      if (ara[j][i] > p[i]) {
        ara[j][i] = p[i];
      }
    }
  }
  cout << "\n";
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cout << ara[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
