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