#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > vp, pp;
int h[105][105];
int a[105], b[104];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int x;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> h[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (h[i][j] == 1) h[i][j] = min(a[j], b[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << h[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
