#include <bits/stdc++.h>
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T>
using vec = std::vector<T>;
template <class T>
using vec2d = std::vector<std::vector<T>>;
template <class T>
vec2d<T> makeVec2d(const int n1, const int n2, const T initValue) {
  return vec2d<T>(n1, vec<T>(n2, initValue));
}
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
struct Input {
  Input(istream &in) : in(&in) {}
  template <class T>
  T next() const {
    T x;
    *in >> x;
    return x;
  }
  int ni() const { return next<int>(); }
  template <class T>
  vec<T> nVec(int n) const {
    vec<T> v(n);
    for (int i = 0; i < n; ++i) {
      v[i] = next<T>();
    }
    return v;
  }
  vec<int> nvi(int n) const { return nVec<int>(n); }
  istream *in;
};
Input in(cin);
class Output {
 private:
  ostream *out;
  template <typename T>
  void printSingle(const T &value) {
    *out << value;
  }
  template <typename T>
  void printSingle(const vec<T> &v) {
    for (std::size_t i = 0; i < v.size(); ++i) {
      if (i == 0) {
        printSingle(v[i]);
      } else {
        *out << ' ';
        printSingle(v[i]);
      }
    }
  }

 public:
  Output(ostream &out) : out(&out) {}
  inline void print() {}
  template <typename T, typename... Ts>
  inline void print(const T &f, const Ts &...args) {
    printSingle(f);
    if (sizeof...(args) != 0) {
      *out << ' ';
      print(args...);
    }
  }
  template <typename... Ts>
  inline void println(const Ts &...args) {
    print(args...);
    (*out) << '\n';
  }
  template <typename... Ts>
  inline void operator()(const Ts &...args) {
    println(args...);
  }
};
Output out(cout);
namespace template_util {
constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }
template <int N>
struct bytetype {};
template <uint64_t N>
struct minimal_uint : bytetype<bytecount(N)> {};
}  // namespace template_util
void solve(istream &inStream, ostream &outStream) {
  in = Input(inStream);
  out = Output(outStream);
  auto n = in.ni();
  auto m = in.ni();
  auto h = in.ni();
  auto a = in.nvi(m);
  auto b = in.nvi(n);
  vec2d<int> mat(n);
  vec2d<int> result = makeVec2d<int>(n, m, 0);
  for (int i = 0; i < (n); ++i) {
    mat[i] = in.nvi(m);
    for (int j = 0; j < (m); ++j) {
      if (mat[i][j] == 0) {
        result[i][j] = 0;
      }
    }
  }
  for (int curH = h; curH >= 0; --curH) {
    vec<int> xs, ys;
    for (int i = 0; i < (n); ++i) {
      if (b[i] == curH) {
        xs.push_back(i);
      }
    }
    for (int i = 0; i < (m); ++i) {
      if (a[i] == curH) {
        ys.push_back(i);
      }
    }
    for (int i = 0; i < (xs.size()); ++i) {
      for (int j = 0; j < (ys.size()); ++j) {
        if (mat[xs[i]][ys[j]] == 1) {
          result[xs[i]][ys[j]] = curH;
        }
      }
    }
    for (int i = 0; i < (xs.size()); ++i) {
      for (int j = 0; j < (m); ++j) {
        if (a[j] > curH) {
          if (mat[xs[i]][j] == 1) {
            result[xs[i]][j] = curH;
          }
        }
      }
    }
    for (int i = 0; i < (ys.size()); ++i) {
      for (int j = 0; j < (n); ++j) {
        if (b[j] > curH) {
          if (mat[j][ys[i]] == 1) {
            result[j][ys[i]] = curH;
          }
        }
      }
    }
  }
  for (int i = 0; i < (n); ++i) {
    out(result[i]);
  }
}
int main() {
  solve(cin, cout);
  return 0;
}
