#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using std::cin;
using std::cout;
using LL = long long;
using db = double;
using pii = std::pair<int, int>;
using vi = std::vector<int>;
void solve() {
  int n, m, h;
  cin >> n >> m >> h;
  vi a(m), b(n);
  std::vector<vi> c(n, vi(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, x; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> x;
      if (x == 0)
        cout << "0 ";
      else
        cout << std::min(a[j], b[i]) << " ";
    }
    cout << "\n";
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}
