#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, h;
  cin >> n >> m >> h;
  int a[105][105] = {0};
  int x[105] = {0}, y[105] = {0};
  for (int i = 1; i <= m; i++) cin >> x[i];
  for (int i = 1; i <= n; i++) cin >> y[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] != 0) {
        a[i][j] = min(x[j], y[i]);
      }
    }
  }
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}
