#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, h, *mm, *nn, **t;
  cin >> n >> m >> h;
  mm = new int[m];
  nn = new int[n];
  for (int i = 0; i < m; i++) {
    cin >> mm[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> nn[i];
  }
  t = new int*[n];
  for (int i = 0; i < n; i++) {
    t[i] = new int[m];
    for (int j = 0; j < m; j++) {
      cin >> t[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (t[i][j] == 1 && mm[j] <= nn[i]) {
        t[i][j] = mm[j];
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (t[j][i] == 1 && nn[j] <= mm[i]) {
        t[j][i] = nn[j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << t[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
