#include <bits/stdc++.h>
using namespace std;
const double inf = 1e9;
const double eps = 0;
const int ms = 0;
const int md = 0;
const int N = 105;
int n, m, h;
int a[N], b[N], mt[N][N];
vector<int> fr[N], lef[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> h;
  for (__typeof(1) i = 1; i < m + 1; i++) cin >> a[i];
  for (__typeof(1) i = 1; i < n + 1; i++) cin >> b[i];
  for (__typeof(1) i = 1; i < n + 1; i++) {
    for (__typeof(1) j = 1; j < m + 1; j++) {
      cin >> mt[i][j];
      if (mt[i][j] > 0) {
        fr[j].push_back(i);
        lef[i].push_back(j);
      }
    }
  }
  for (__typeof(1) i = 1; i < m + 1; i++) {
    for (__typeof(fr[i].begin()) j = fr[i].begin(); j != fr[i].end(); j++) {
      mt[*j][i] = a[i];
    }
  }
  for (__typeof(1) i = 1; i < n + 1; i++) {
    for (__typeof(lef[i].begin()) j = lef[i].begin(); j != lef[i].end(); j++) {
      mt[i][*j] = min(b[i], mt[i][*j]);
    }
  }
  for (__typeof(1) i = 1; i < n + 1; i++) {
    for (__typeof(1) j = 1; j < m + 1; j++) {
      cout << mt[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
