#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 101;
const int MAX_M = 101;
int A[MAX_N], B[MAX_M];
int top_view[MAX_N][MAX_M];
int ans[MAX_N][MAX_M];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, H;
  cin >> N >> M >> H;
  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 >> top_view[i][j];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (top_view[i][j]) {
        ans[i][j] = A[j];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (ans[i][j] > B[i]) {
        ans[i][j] = B[i];
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) cout << ans[i][j] << (j == M - 1 ? '\n' : ' ');
  }
  return 0;
}
