#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, h, i, j;
  cin >> n >> m >> h;
  long long int a[n][m];
  long long int r[n], c[m];
  for (i = 0; i < m; i++) cin >> c[i];
  for (i = 0; i < n; i++) cin >> r[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> a[i][j];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] != 0) a[i][j] = -1;
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++) {
      if (a[i][j] == 0) continue;
      if (c[j] <= r[i]) a[i][j] = c[j];
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == 0) continue;
      if (a[i][j] == -1)
        if (c[j] >= r[i]) a[i][j] = r[i];
    }
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] == -1) a[i][j] = 1;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
