#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long llinf = 1e18;
const long long nax = 0;
int r[105], c[105], arr[105][105], ans[105][105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int n, m, h;
  cin >> n >> m >> h;
  for (int i = 1; i <= m; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> r[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> arr[i][j];
    }
  }
  for (int j = 1; j <= m; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (arr[i][j] > 0) ans[i][j] = c[j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (arr[i][j] > 0) ans[i][j] = min(r[i], ans[i][j]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
}
