#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  int front_view[105];
  int left_view[105];
  int top_view[105][105];
  int grid_view[105][105];
  for (int i = 0; i < m; i++) cin >> front_view[i];
  for (int i = 0; i < n; i++) cin >> left_view[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> top_view[i][j];
  memset(grid_view, 0, sizeof(grid_view));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (top_view[i][j] == 1) {
        grid_view[i][j] = min(front_view[j], left_view[i]);
      }
    }
  for (int i = 0; i < n; i++) {
    cout << endl;
    for (int j = 0; j < m; j++) cout << grid_view[i][j] << " ";
  }
  return 0;
}
