#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, h;
  cin >> n >> m >> h;
  int masN[n], masM[m], masH[n][m];
  for (int i = 0; i < m; i++) {
    cin >> masM[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> masN[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> masH[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (masH[i][j] == 1) {
        cout << min(masN[i], masM[j]) << " ";
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
}
int main() {
  int k = 1;
  for (int i = 0; i < k; i++) {
    solve();
  }
  return 0;
}
