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