#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, h, i, j;
  cin >> n >> m >> h;
  long long a[m];
  for (long long i = 0; i < m; i++) cin >> a[i];
  ;
  long long b[n];
  for (long long i = 0; i < n; i++) cin >> b[i];
  ;
  long long c[n][m];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> c[i][j];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (b[i] <= a[j] && c[i][j] != 0) c[i][j] = b[i];
    }
  }
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++) {
      if (a[j] <= b[i] && c[i][j] != 0) c[i][j] = a[j];
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
}
