#include <bits/stdc++.h>
using namespace std;
const double inf = 1e9;
const double eps = 0;
const int ms = 0;
const int md = 0;
const int N = 105;
int n, m, h, x;
int a[N], b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> h;
  for (__typeof(1) i = 1; i < m + 1; i++) {
    cin >> a[i];
  }
  for (__typeof(1) i = 1; i < n + 1; i++) {
    cin >> b[i];
  }
  for (__typeof(1) i = 1; i < n + 1; i++) {
    for (__typeof(1) j = 1; j < m + 1; j++) {
      cin >> x;
      if (x)
        cout << min(a[j], b[i]) << " ";
      else
        cout << "0 ";
    }
    cout << "\n";
  }
  return 0;
}
