#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> mm(m);
  for (int i = 0; i < m; ++i) cin >> mm[i];
  vector<int> nn(n);
  for (int i = 0; i < n; ++i) cin >> nn[i];
  int mat[n][m];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> mat[i][j];
      if (mat[i][j] == 1) mat[i][j] = min(mm[j], nn[i]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << mat[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
