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