#include <bits/stdc++.h>
using namespace std;
long long getM(const vector<long long>& V) {
  long long k = 0;
  for (long long i = 1; i < V.size(); i++)
    if (V[i] > V[k]) k = i;
  return k;
}
int main() {
  long long n, m, h;
  cin >> n >> m >> h;
  vector<long long> front(m);
  vector<long long> left(n);
  vector<vector<long long> > tabla(n, vector<long long>(m, 0));
  for (long long i = 0; i < m; i++) cin >> front[i];
  for (long long j = 0; j < n; j++) cin >> left[j];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) cin >> tabla[i][j];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (tabla[i][j] == 1) {
        tabla[i][j] = min(front[j], left[i]);
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cout << tabla[i][j] << " ";
    cout << endl;
  }
}
