#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MAXN = 100 + 3;
stringstream ss;
int n, m, h, f[MAXN], l[MAXN], t[MAXN][MAXN];
int main() {
  cin >> n >> m >> h;
  for (int i = 0; i < (int)(m); i++) {
    cin >> f[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    cin >> l[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(m); j++) {
      cin >> t[i][j];
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(m); j++) {
      cout << (t[i][j] ? min(f[j], l[i]) : 0) << " ";
    }
    cout << endl;
  }
  return 0;
}
