#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string s;
long long ans;
bool flag;
void solve() {
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> front(m);
  vector<int> left(n);
  int grid[n][m];
  for (auto i = 0; i < m; i++) cin >> front[i];
  ;
  for (auto i = 0; i < n; i++) cin >> left[i];
  ;
  for (auto i = 0; i < n; i++)
    for (auto j = 0; j < m; j++) cin >> grid[i][j];
  for (auto i = 0; i < n; i++) {
    if (left[i] > 1) {
      int x = left[i];
      for (auto j = 0; j < m; j++) {
        if (grid[i][j] != 0 && front[j] >= x) {
          grid[i][j] = x;
        }
      }
    }
  }
  for (auto j = 0; j < m; j++) {
    if (front[j] > 1) {
      int x = front[j];
      for (auto i = 0; i < n; i++) {
        if (grid[i][j] != 0 && left[i] >= x) {
          grid[i][j] = x;
        }
      }
    }
  }
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < m; j++) cout << grid[i][j] << ' ';
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
