#include <bits/stdc++.h>
using namespace std;
template <class T>
std::istream& operator>>(std::istream& in, std::vector<T>& data) {
  for (auto& item : data) {
    in >> item;
  }
  return in;
}
template <class T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& data) {
  bool first = true;
  for (const auto& item : data) {
    if (!first) {
      out << " ";
    }
    out << item;
    first = false;
  }
  return out;
}
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> heights_1(m);
  vector<int> heights_2(n);
  cin >> heights_1 >> heights_2;
  vector<vector<int>> mask(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> mask[i];
  }
  vector<vector<int>> res(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (mask[i][j] == 0) {
        res[i][j] = 0;
      } else {
        res[i][j] = min(heights_1[j], heights_2[i]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << res[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
