#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m, h;
  cin >> n >> m >> h;
  vector<int> c(m), r(n), cnt(m);
  for (int i = 0; i < m; i++) cin >> c[i];
  for (int i = 0; i < n; i++) cin >> r[i];
  vector<vector<int>> v(n, vector<int>(m)), a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> v[i][j];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) cnt[i] += v[j][i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == 1) {
        if (r[i] == c[j] and cnt[j] > 0) {
          a[i][j] = r[i];
          cnt[j]--;
          break;
        } else if (r[i] < c[j] and cnt[j] > 1) {
          a[i][j] = r[i];
          cnt[j]--;
          break;
        }
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (v[j][i] == 1 and a[j][i] == 0) {
        if (c[i] > r[j])
          a[j][i] = r[j];
        else
          a[j][i] = c[i];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << a[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
