//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <sys/time.h>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

double rem_time;

void init_time()
{
    timeval tv;
    gettimeofday(&tv, 0);
    rem_time=tv.tv_sec+tv.tv_usec*1e-6;
}

inline double get_time()
{
    timeval tv;
    gettimeofday(&tv, 0);
    return tv.tv_sec+tv.tv_usec*1e-6 - rem_time;
}

void nope()
{
	printf("-1\n");
	exit(0);
}

int n, m, k;
int r;

int q;
vector <pair<int,vi> > wary;

int num(int a, int b, int c)
{
	a--;
	b--;
	c--;
	return a*m*k+b*k+c;
}

vi mago[nax];

int tab[nax];

int spoko(int v)
{
	if (!wary[v].first)
	{
		for (int i : wary[v].second)
			if (tab[i])
				return 0;
		return 1;
	}
	for (int i : wary[v].second)
		if (tab[i])
			return (tab[i]==wary[v].first);
	return 0;
}

int los()
{
	const static ll mno=1e6;
	const static ll mod=1e9;
	return (rand()+mno*rand())%mod;
}

int main()
{
	init_time();
	scanf("%d%d%d", &n, &m, &k);
	r=n*m*k;
	{
		for (int i=1; i<=m; i++)
		{
			for (int j=1; j<=k; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=1; l<=n; l++)
					wary.back().second.push_back(num(l, i, j));
			}
		}
	}
	{
		for (int i=1; i<=m; i++)
		{
			for (int j=1; j<=k; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=n; l; l--)
					wary.back().second.push_back(num(l, i, j));
			}
		}
	}
	{
		for (int i=1; i<=n; i++)
		{
			for (int j=1; j<=k; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=1; l<=m; l++)
					wary.back().second.push_back(num(i, l, j));
			}
		}
	}
	{
		for (int i=1; i<=n; i++)
		{
			for (int j=1; j<=k; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=m; l; l--)
					wary.back().second.push_back(num(i, l, j));
			}
		}
	}
	{
		for (int i=1; i<=n; i++)
		{
			for (int j=1; j<=m; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=1; l<=k; l++)
					wary.back().second.push_back(num(i, j, l));
			}
		}
	}
	{
		for (int i=1; i<=n; i++)
		{
			for (int j=1; j<=m; j++)
			{
				int x;
				scanf("%d", &x);
				wary.push_back({x, {}});
				for (int l=k; l; l--)
					wary.back().second.push_back(num(i, j, l));
			}
		}
	}
	q=wary.size();
	debug() << imie(r) << imie(q);
	for (int i=0; i<q; i++)
		for (int j : wary[i].second)
			mago[j].push_back(i);
	//~ while(get_time())
	int zado=0;
	for (int i=0; i<q; i++)
		zado+=spoko(i);
	srand(time(0));
	while(zado<q && get_time()<2.9)
	{
		int v=los()%r;
		int ter=0;
		for (int i : mago[v])
			if (spoko(i))
				ter++;
		zado-=ter;
		//~ if (ter==6)
			//~ continue;
		vi opc{0};
		for (int i : mago[v])
			opc.push_back(wary[i].first);
		sort(opc.begin(), opc.end());
		opc.resize(unique(opc.begin(), opc.end())-opc.begin());
		vi moge;
		for (int i=0; i<(int)opc.size(); i++)
		{
			tab[v]=opc[i];
			int ter=0;
			for (int j : mago[v])
				if (spoko(j))
					ter++;
			moge.push_back(ter);
		}
		int naj=0;
		for (int i : moge)
			naj=max(naj, i);
		vi faj;
		for (int i=0; i<(int)opc.size(); i++)
			if (moge[i]==naj)
				faj.push_back(opc[i]);
		int x=faj[rand()%faj.size()];
		tab[v]=x;
		zado+=naj;
	}
	if (zado==q)
	{
		for (int i=0; i<r; i++)
			printf("%d ", tab[i]);
		printf("\n");
	}
	else
	{
		nope();
	}
	return 0;
}
