#include <bits/stdc++.h>
using namespace std;
long long lef[101], fron[101], mat[101][101];
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 0; i < m; i++) cin >> fron[i];
  for (int i = 0; i < n; i++) cin >> lef[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> mat[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] && lef[i] >= fron[j]) {
        mat[i][j] = fron[j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == 1 && lef[i] <= fron[j]) {
        mat[i][j] = lef[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << mat[i][j];
      if (j < m - 1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
