#include <bits/stdc++.h>
using namespace std;
using cat = long long;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int N[3];
  for (int i = 0; i < 3; i++) cin >> N[i];
  vector<vector<int> > A[3][2];
  int dim[3][2];
  for (int k = 0; k < 3; k++)
    for (int l = 0; l < 2; l++) {
      dim[k][0] = k ? 0 : 1;
      dim[k][1] = 3 - k - dim[k][0];
      A[k][l].resize(N[dim[k][0]], vector<int>(N[dim[k][1]]));
      for (int i = 0; i < N[dim[k][0]]; i++)
        for (int j = 0; j < N[dim[k][1]]; j++) cin >> A[k][l][i][j];
    }
  vector<vector<vector<int> > > ans(
      N[0], vector<vector<int> >(N[1], vector<int>(N[2], -1)));
  for (int k = 0; k < 3; k++)
    for (int i = 0; i < N[dim[k][0]]; i++)
      for (int j = 0; j < N[dim[k][1]]; j++)
        if (!A[k][0][i][j] || !A[k][1][i][j]) {
          if (A[k][0][i][j] || A[k][1][i][j]) {
            cout << "-1\n";
            return 0;
          }
          int idx[3];
          idx[dim[k][0]] = i;
          idx[dim[k][1]] = j;
          for (idx[k] = 0; idx[k] < N[k]; idx[k]++)
            ans[idx[0]][idx[1]][idx[2]] = 0;
        }
  for (int r = 0; r < 2; r++)
    for (int c = 0; c < 8; c++) {
      vector<vector<vector<int> > > border(
          N[0], vector<vector<int> >(N[1], vector<int>(N[2], 0)));
      vector<vector<vector<int> > > cur(
          N[0], vector<vector<int> >(N[1], vector<int>(N[2], -1)));
      for (int i = 0; i < N[0]; i++)
        for (int j = 0; j < N[1]; j++)
          for (int k = 0; k < N[2]; k++) {
            if (i == 0) border[i][j][k] |= 1;
            if (j == 0) border[i][j][k] |= 2;
            if (k == 0) border[i][j][k] |= 4;
            int i_r = i, j_r = j, k_r = k;
            if (c & 1) i_r = N[0] - 1 - i;
            if (c & 2) j_r = N[1] - 1 - j;
            if (c & 4) k_r = N[2] - 1 - k;
            if (ans[i][j][k] == 0) cur[i_r][j_r][k_r] = 0;
          }
      vector<vector<int> > B[3];
      for (int k = 0; k < 3; k++) {
        int x = (c >> k) & 1;
        B[k].resize(N[dim[k][0]], vector<int>(N[dim[k][1]], 0));
        for (int i = 0; i < N[dim[k][0]]; i++)
          for (int j = 0; j < N[dim[k][1]]; j++) {
            int i_r = i, j_r = j;
            if ((c >> dim[k][0]) & 1) i_r = N[dim[k][0]] - 1 - i;
            if ((c >> dim[k][1]) & 1) j_r = N[dim[k][1]] - 1 - j;
            B[k][i_r][j_r] = A[k][x][i][j];
          }
      }
      for (int i = 0; i < N[0]; i++)
        for (int j = 0; j < N[1]; j++)
          for (int k = 0; k < N[2]; k++) {
            if (!border[i][j][k]) continue;
            int idx[3] = {i, j, k};
            if (cur[i][j][k] == -1)
              for (int l = 0; l < 3; l++)
                if ((border[i][j][k] >> l) & 1) {
                  if (cur[i][j][k] == -1)
                    cur[i][j][k] = B[l][idx[dim[l][0]]][idx[dim[l][1]]];
                  else if (cur[i][j][k] != B[l][idx[dim[l][0]]][idx[dim[l][1]]])
                    cur[i][j][k] = 0;
                }
            int b = border[i][j][k];
            if (cur[i][j][k] == 0) {
              for (int l = 0; l < 3; l++) {
                idx[l]++;
                if (idx[l] != N[l])
                  border[idx[0]][idx[1]][idx[2]] |= b & (1 << l);
                idx[l]--;
              }
            } else {
            }
          }
      for (int i = 0; i < N[0]; i++)
        for (int j = 0; j < N[1]; j++)
          for (int k = 0; k < N[2]; k++) {
            int i_r = i, j_r = j, k_r = k;
            if (c & 1) i_r = N[0] - 1 - i;
            if (c & 2) j_r = N[1] - 1 - j;
            if (c & 4) k_r = N[2] - 1 - k;
            if (cur[i][j][k] != -1) {
              if (ans[i_r][j_r][k_r] != -1 &&
                  cur[i][j][k] != ans[i_r][j_r][k_r])
                ans[i_r][j_r][k_r] = 0;
              else
                ans[i_r][j_r][k_r] = cur[i][j][k];
            }
          }
    }
  for (int k = 0; k < 3; k++)
    for (int i = 0; i < N[dim[k][0]]; i++)
      for (int j = 0; j < N[dim[k][1]]; j++)
        if (A[k][0][i][j]) {
          int idx[3];
          idx[dim[k][0]] = i;
          idx[dim[k][1]] = j;
          idx[k] = 0;
          while (idx[k] < N[k] && !ans[idx[0]][idx[1]][idx[2]]) idx[k]++;
          if (idx[k] == N[k] || ans[idx[0]][idx[1]][idx[2]] != A[k][0][i][j]) {
            cout << "-1\n";
            return 0;
          }
          idx[k] = N[k] - 1;
          while (idx[k] >= 0 && !ans[idx[0]][idx[1]][idx[2]]) idx[k]--;
          if (idx[k] == -1 || ans[idx[0]][idx[1]][idx[2]] != A[k][1][i][j]) {
            cout << "-1\n";
            return 0;
          }
        }
  for (int i = 0; i < N[0]; i++)
    for (int j = 0; j < N[1]; j++)
      for (int k = 0; k < N[2]; k++)
        if (ans[i][j][k] == -1) ans[i][j][k] = 0;
  for (int i = 0; i < N[0]; i++) {
    if (i) cout << "\n";
    for (int j = 0; j < N[1]; j++)
      for (int k = 0; k < N[2]; k++)
        cout << ans[i][j][k] << ((k == N[2] - 1) ? "\n" : " ");
  }
  return 0;
}
