#include <bits/stdc++.h>
using namespace std;
const long long mx = 1e2 + 5;
long long n, s[mx], r[mx], arr[mx][mx], h, m, yek = 1;
bool mark[mx][mx];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> h;
  for (int i = 0; i < m; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mark[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (mark[j][i] == 1 && r[j] >= s[i]) {
        arr[j][i] = s[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mark[i][j] == 1 && arr[i][j] == 0 && s[j] >= r[i]) {
        arr[i][j] = r[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mark[i][j]) {
        cout << max(yek, arr[i][j]) << " ";
      } else {
        cout << 0 << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
