#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int n, m, h;
  cin >> n >> m >> h;
  int res[n + 1][m + 1], front[m + 1], left[n + 1], top[n + 1][m + 1];
  for (int i = 1; i < (m + 1); ++i) {
    cin >> front[i];
  }
  for (int i = 1; i < (n + 1); ++i) {
    cin >> left[i];
  }
  for (int i = 1; i < (n + 1); ++i) {
    for (int j = 1; j < (m + 1); ++j) {
      cin >> top[i][j];
    }
  }
  for (int j = 1; j < (m + 1); ++j) {
    for (int i = n; i >= 0; i--) {
      if (top[i][j] && left[i] >= front[j]) top[i][j] = front[j];
    }
  }
  for (int i = 1; i < (n + 1); ++i) {
    for (int j = m; j >= 0; j--) {
      if (top[i][j] && front[j] >= left[i]) top[i][j] = left[i];
    }
  }
  for (int i = 1; i < (n + 1); ++i) {
    cout << top[i][1];
    for (int j = 2; j < (m + 1); ++j) {
      cout << " " << top[i][j];
    }
    cout << "\n";
  }
  return 0;
}
