#include <bits/stdc++.h>
using namespace std;
long long sleva[300];
long long speredi[300];
long long matrix[300][300];
long long n, m, h;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin >> n >> m >> h;
  for (long long i = 1; i <= m; i++) {
    cin >> speredi[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> sleva[i];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> matrix[i][j];
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (matrix[i][j]) {
        matrix[i][j] = min(speredi[j], sleva[i]);
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cout << matrix[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
