#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, m, h;
  cin >> n >> m >> h;
  int arr[m], brr[n], ans[n][m], tp[n][m];
  for (int i = 0; i < m; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) cin >> brr[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> tp[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (tp[i][j] == 0)
        cout << 0 << " ";
      else
        cout << min(arr[j], brr[i]) << " ";
    }
    cout << endl;
  }
  return 0;
}
