#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ht;
  cin >> n >> m >> ht;
  int a[m], b[n];
  int h[n][m];
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> h[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!h[i][j])
        cout << h[i][j] << " ";
      else if (b[i] == a[j])
        cout << a[j] << " ";
      else
        cout << min(b[i], a[j]) << " ";
    }
    cout << endl;
  }
  return 0;
}
