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