#include <bits/stdc++.h>
using namespace std;
int sol[123123];
int on[123123];
int matrix[142][142];
int matrix_2[142][142];
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= m; i++) cin >> on[i];
  for (int i = 1; i <= n; i++) cin >> sol[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> matrix[i][j];
      matrix_2[i][j] = 31231212;
    }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (matrix_2[j][i] > on[i]) matrix_2[j][i] = on[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (matrix_2[i][j] > sol[i]) matrix_2[i][j] = sol[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (matrix[i][j])
        cout << matrix_2[i][j] << " ";
      else
        cout << "0 ";
    cout << "\n";
  }
  return 0;
}
