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