#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) { return a < b ? a : b; }
int main() {
  long long n, m, h, x;
  cin >> n >> m >> h;
  int a[m], b[n], c[n][m];
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      if (x == 1) {
        c[i][j] = min(b[i], a[j]);
      } else
        c[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << c[i][j] << " ";
    cout << endl;
  }
  return 0;
}
