#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, h;
  cin >> n >> m >> h;
  long long r[n], c[m], a[n][m];
  for (long long i = 0; i < m; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (r[i] == c[j] && a[i][j] == 1) {
        a[i][j] = r[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 1) {
        a[i][j] = min(r[i], c[j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
