#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int n, m, h;
    cin >> n >> m >> h;
    long long int a[m + 1], b[n + 1], arr[n + 1][m + 1];
    for (long long int i = 1; i <= m; i++) cin >> a[i];
    for (long long int i = 1; i <= n; i++) cin >> b[i];
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= m; j++) {
        cin >> arr[i][j];
      }
    }
    long long int ans[n + 1][m + 1];
    memset(ans, 0, sizeof(ans));
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= m; j++) {
        if (arr[i][j] == 1 && a[j] >= b[i]) {
          ans[i][j] = b[i];
          break;
        }
      }
    }
    for (long long int j = 1; j <= m; j++) {
      for (long long int i = 1; i <= n; i++) {
        if (arr[i][j] == 1 && b[i] >= a[j]) {
          ans[i][j] = a[j];
          break;
        }
      }
    }
    for (long long int i = 1; i <= n; i++) {
      for (long long int j = 1; j <= m; j++) {
        cout << max(ans[i][j], arr[i][j]) << " ";
      }
      cout << '\n';
    }
  }
  return 0;
}
