#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
int a[105], b[105], c[105][105];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> c[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c[i][j] == 1) c[i][j] = min(a[j], b[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << c[i][j] << ' ';
    cout << '\n';
  }
}
