#include <bits/stdc++.h>
using namespace std;
int grid[105][105];
int main() {
  memset(grid, 0, sizeof(grid));
  int n, m, h;
  scanf("%d %d %d", &n, &m, &h);
  vector<int> row, col;
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    col.push_back(a);
  }
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    row.push_back(b);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int gg;
      scanf("%d", &gg);
      if (!gg) continue;
      grid[i][j] = min(row[i], col[j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", grid[i][j]);
    }
    printf("\n");
  }
  return 0;
}
