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