#include <bits/stdc++.h>
#define re register
#define rep(x,a,b) for (re int x=a;x<=b;++x)
#define drp(x,a,b) for (re int x=a;x>=b;--x)
#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
const int N=1e5+1;
int n,Q,num[N],A[N];
LL L[N],R[N],E[N],B[N];
multiset<LL> Ans,S[N];
multiset<LL>::iterator iter;
inline void Cal(int x){E[x]=B[x]/(num[x]+2);L[x]=B[x]-(num[x]+1)*E[x];}
inline void Add(int x) {S[A[x]].insert(L[x]+R[x]);}
inline void add(int x){
	if (S[x].empty()) return;
	iter=S[x].begin();Ans.insert(*iter+E[x]);
	iter=S[x].end();iter--;Ans.insert(*iter+E[x]);
}
inline void Rom(int x) {S[A[x]].erase(S[A[x]].find(L[x]+R[x]));}
inline void rom(int x){
	if (S[x].empty()) return;
	iter=S[x].begin();Ans.erase(Ans.find(*iter+E[x]));
	iter=S[x].end();iter--;Ans.erase(Ans.find(*iter+E[x]));
}
inline void operate1 (int x){
	rom(A[x]),rom(A[A[x]]),rom(A[A[A[x]]]);
	Rom(x),Rom(A[x]),Rom(A[A[x]]);
	R[A[x]]-=E[x],--num[A[x]];
	R[A[A[x]]]-=E[A[x]];
}
inline void operate2(int x){
	R[A[A[x]]]+=E[A[x]];
	Add(A[x]),Add(A[A[x]]);
	add(A[x]),add(A[A[x]]),add(A[A[A[x]]]);
}
inline void operate3(int x){
	rom(A[x]),rom(A[A[x]]),rom(A[A[A[x]]]);
	Rom(A[x]),Rom(A[A[x]]);
	R[A[x]]+=E[x],++num[A[x]];
	R[A[A[x]]]-=E[A[x]];
}
inline void operate4(int x){
	R[A[A[x]]]+=E[A[x]];
	Add(x),Add(A[x]),Add(A[A[x]]);
	add(A[x]),add(A[A[x]]),add(A[A[A[x]]]);
}
signed main(){
//	freopen("forest.in","r",stdin);
//	freopen("forest.out","w",stdout);
	scanf("%d%d",&n,&Q);
	rep(i,1,n) scanf("%lld",&B[i]);
	rep(i,1,n) scanf("%d",&A[i]),++num[A[i]];
	rep(i,1,n) Cal(i),R[A[i]]+=E[i];
	rep(i,1,n) Add(i);rep(i,1,n) add(i);
	while (Q--){
		int opt,x,y;
		scanf("%d",&opt);
		if (opt==2) {scanf("%d",&x);printf("%lld\n",R[x]+L[x]+E[A[x]]);}
			else if (opt==3) {
				iter=Ans.begin();printf("%lld ",*iter);
				iter=Ans.end(),iter--;printf("%lld\n",*iter);
			} else {
				scanf("%d%d",&x,&y);
				if (A[x]==y) continue;
				operate1(x);
				Cal(A[x]);
				operate2(x);
				A[x]=y;
				operate3(x);
				Cal(A[x]);
				operate4(x);
			}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200005
multiset<ll> val[maxn],all;
int n,q,f[maxn],deg[maxn];
ll c[maxn],v[maxn];
void Add(int x)
{
	//printf("%lld--------\n",*val[x].rbegin()+c[x]/(deg[x]+2));
	if(!val[x].size()) return;
	all.insert(*val[x].begin()+c[x]/(deg[x]+2));
	all.insert(*val[x].rbegin()+c[x]/(deg[x]+2));
}
void Del(int x)
{
	if(!val[x].size()) return;
	all.erase(all.find(*val[x].begin()+c[x]/(deg[x]+2)));
	all.erase(all.find(*val[x].rbegin()+c[x]/(deg[x]+2)));
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++) scanf("%lld",&c[i]);
	for(int i=1;i<=n;i++) scanf("%d",&f[i]),deg[f[i]]++;
	for(int i=1;i<=n;i++)
	{
		v[f[i]]+=c[i]/(deg[i]+2);
		v[i]+=c[i]-(deg[i]+1)*(c[i]/(deg[i]+2));
	}
	for(int i=1;i<=n;i++) val[f[i]].insert(v[i]);
	for(int i=1;i<=n;i++)
		if(deg[i]) Add(i);
	while(q--)
	{
		int ty,x,y,t;
		scanf("%d",&ty);
		if(ty==1)
		{
			scanf("%d%d",&x,&y);

			Del(f[x]),val[f[x]].erase(val[f[x]].find(v[x]));

			t=f[x],Del(f[t]),Del(f[f[t]]);
			val[f[t]].erase(val[f[t]].find(v[t]));
			val[f[f[t]]].erase(val[f[f[t]]].find(v[f[t]]));

			v[f[t]]-=c[t]/(deg[t]+2);

			v[t]-=c[t]-(deg[t]+1)*(c[t]/(deg[t]+2))+(c[x]/(deg[x]+2)),deg[t]--;
			v[t]+=c[t]-(deg[t]+1)*(c[t]/(deg[t]+2));

			v[f[t]]+=c[t]/(deg[t]+2);

			Add(t);
			val[f[t]].insert(v[t]),Add(f[t]);
			val[f[f[t]]].insert(v[f[t]]),Add(f[f[t]]);

			//----------------------------

			f[x]=y;

			Del(y),val[y].insert(v[x]);

			Del(f[y]),val[f[y]].erase(val[f[y]].find(v[y]));
			Del(f[f[y]]),val[f[f[y]]].erase(val[f[f[y]]].find(v[f[y]]));

			v[f[y]]-=c[y]/(deg[y]+2);

			v[y]-=c[y]-(deg[y]+1)*(c[y]/(deg[y]+2)),deg[y]++;
			v[y]+=c[y]-(deg[y]+1)*(c[y]/(deg[y]+2))+(c[x]/(deg[x]+2));

			v[f[y]]+=c[y]/(deg[y]+2);

			Add(y);
			val[f[y]].insert(v[y]),Add(f[y]);
			val[f[f[y]]].insert(v[f[y]]),Add(f[f[y]]);
		}
		else if(ty==2) scanf("%d",&x),printf("%lld\n",v[x]+(c[f[x]]/(deg[f[x]]+2)));
		else printf("%lld %lld\n",*all.begin(),*all.rbegin());
	}
	return 0;
}


//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int &n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 1e5 + 7;
int n, q, d[N], f[N];
bool v[N];
ll a[N], t[N];
multiset<ll> s[N];

inline void del(int x) {
//	debug("del x = %d\n", x);
	if (v[x] && s[x].size())
		v[x] = 0,
//		debug("del %lld\n", (*s[x].begin()) + t[x] / (d[x] + 1)),
//		debug("del %lld\n", (*(--s[x].end())) + t[x] / (d[x] + 1)),
		s[0].erase(s[0].find((*s[x].begin()) + t[x] / (d[x] + 1))),
		s[0].erase(s[0].find((*(--s[x].end())) + t[x] / (d[x] + 1)));
}

inline void add(int x) {
//	debug("add x = %d\n", x);
	if (!v[x] && s[x].size())
		v[x] = 1,
//		debug("add %lld\n", (*s[x].begin()) + t[x] / (d[x] + 1)),
//		debug("add %lld\n", (*(--s[x].end())) + t[x] / (d[x] + 1)),
		s[0].insert((*s[x].begin()) + t[x] / (d[x] + 1)),
		s[0].insert((*(--s[x].end())) + t[x] / (d[x] + 1));
}

inline void work(int i, int j) {
	del(f[i]), del(f[f[i]]), del(f[f[f[i]]]);
	del(j), del(f[j]), del(f[f[j]]);

	s[f[i]].erase(s[f[i]].find(a[i]));

	s[f[f[i]]].erase(s[f[f[i]]].find(a[f[i]]));
	a[f[i]] -= t[i] / (d[i] + 1);
	a[f[i]] -= t[f[i]] - d[f[i]] * (t[f[i]] / (d[f[i]] + 1));
	a[f[i]] += t[f[i]] - (d[f[i]] - 1) * (t[f[i]] / d[f[i]]);
	s[f[f[i]]].insert(a[f[i]]);

	s[f[f[f[i]]]].erase(s[f[f[f[i]]]].find(a[f[f[i]]]));
	a[f[f[i]]] -= t[f[i]] / (d[f[i]] + 1);
	a[f[f[i]]] += t[f[i]] / d[f[i]];
	s[f[f[f[i]]]].insert(a[f[f[i]]]);

	--d[f[i]], ++d[j];

	s[j].insert(a[i]);

	s[f[j]].erase(s[f[j]].find(a[j]));
	a[j] += t[i] / (d[i] + 1);
	a[j] -= t[j] - (d[j] - 1) * (t[j] / d[j]);
	a[j] += t[j] - d[j] * (t[j] / (d[j] + 1));
	s[f[j]].insert(a[j]);

	s[f[f[j]]].erase(s[f[f[j]]].find(a[f[j]]));
	a[f[j]] -= t[j] / d[j];
	a[f[j]] += t[j] / (d[j] + 1);
	s[f[f[j]]].insert(a[f[j]]);

	add(f[i]), add(f[f[i]]), add(f[f[f[i]]]);
	add(j), add(f[j]), add(f[f[j]]);

	f[i] = j;
}

int main() {
	rd(n), rd(q), rda(t, n), rda(f, n);
	for (int i = 1; i <= n; i++) ++d[i], ++d[f[i]];
	for (int i = 1; i <= n; i++)
		a[i] += t[i] - d[i] * (t[i] / (d[i] + 1)),
		a[f[i]] += t[i] / (d[i] + 1);
	for (int i = 1; i <= n; i++) s[f[i]].insert(a[i]);
	for (int i = 1; i <= n; i++) add(i);
	while (q--) {
		int o, i, j;
		rd(o);
		switch (o) {
			case 1 : rd(i), rd(j), work(i, j); break;
			case 2 : rd(i), print(a[i] + t[f[i]] / (d[f[i]] + 1)); break;
			case 3 : print(*s[0].begin(), ' '), print(*(--s[0].end())); break;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAXN 100005

using namespace std;

static long long t[MAXN];
static int g[MAXN];
static int d[MAXN];
static long long prevsum[MAXN];

static pair<long long, multiset<long long>> prevsets[MAXN];

static multiset<long long> mins;
static multiset<long long> maxs;

long long getValue (int ind)
{
	long long res = prevsum[ind];
	res += t[ind] - (long long)(d[ind] + 1) * (t[ind] / (long long)(d[ind] + 2));
	res += t[g[ind]] / (long long)(d[g[ind]] + 2);
	return res;
}

long long getMin (pair<long long, multiset<long long>> *s)
{
	if (s->second.empty()) return 2000000000000000000LL;
	else return *(s->second.begin()) + s->first;
}

long long getMax (pair<long long, multiset<long long>> *s)
{
	if (s->second.empty()) return -1LL;
	else return *(s->second.rbegin()) + s->first;
}

int main ()
{
	int N, Q;
	scanf("%d %d",&N,&Q);
	int i;
	for (i = 0; i < N; i++)
	{
		scanf("%I64i",&t[i]);
	}
	memset(d,0,sizeof(d));
	memset(prevsum,0,sizeof(prevsum));
	for (i = 0; i < N; i++)
	{
		scanf("%d",&g[i]);
		g[i]--;
		d[g[i]]++;
	}
	for (i = 0; i < N; i++)
	{
		prevsum[g[i]] += t[i] / (long long)(d[i] + 2);
		prevsets[i].first = 0LL;
	}
	for (i = 0; i < N; i++)
	{
		prevsets[g[i]].second.insert(getValue(i));
	}
	for (i = 0; i < N; i++)
	{
		mins.insert(getMin(&prevsets[i]));
		maxs.insert(getMax(&prevsets[i]));
		//printf("%I64i %I64i\n",getMin(&prevsets[i]),getMax(&prevsets[i]));
	}
	int iQ;
	for (iQ = 0; iQ < Q; iQ++)
	{
		int T;
		scanf("%d",&T);
		if (T == 1)
		{
			int v, x, y;
			scanf("%d %d",&v,&y);
			v--; y--;
			x = g[v];

			//printf("OK 0\n");

			mins.erase(mins.find(getMin(&prevsets[g[g[x]]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[g[x]]])));
			prevsets[g[g[x]]].second.erase(prevsets[g[g[x]]].second.find(getValue(g[x]) - prevsets[g[g[x]]].first));
			prevsum[g[x]] -= t[x] / (long long)(d[x] + 2);
			prevsets[g[g[x]]].second.insert(getValue(g[x]) - prevsets[g[g[x]]].first);
			mins.insert(getMin(&prevsets[g[g[x]]]));
			maxs.insert(getMax(&prevsets[g[g[x]]]));

			//printf("OK 1\n");

			mins.erase(mins.find(getMin(&prevsets[g[g[y]]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[g[y]]])));
			prevsets[g[g[y]]].second.erase(prevsets[g[g[y]]].second.find(getValue(g[y]) - prevsets[g[g[y]]].first));
			prevsum[g[y]] -= t[y] / (long long)(d[y] + 2);
			prevsets[g[g[y]]].second.insert(getValue(g[y]) - prevsets[g[g[y]]].first);
			mins.insert(getMin(&prevsets[g[g[y]]]));
			maxs.insert(getMax(&prevsets[g[g[y]]]));

			//printf("OK 2\n");

			mins.erase(mins.find(getMin(&prevsets[x])));
			maxs.erase(maxs.find(getMax(&prevsets[x])));
			mins.erase(mins.find(getMin(&prevsets[y])));
			maxs.erase(maxs.find(getMax(&prevsets[y])));
			prevsets[g[v]].second.erase(prevsets[g[v]].second.find(getValue(v) - prevsets[g[v]].first));
			g[v] = y;
			prevsets[g[v]].second.insert(getValue(v) - prevsets[g[v]].first);
			mins.insert(getMin(&prevsets[x]));
			maxs.insert(getMax(&prevsets[x]));
			mins.insert(getMin(&prevsets[y]));
			maxs.insert(getMax(&prevsets[y]));

			//printf("OK 3\n");

			mins.erase(mins.find(getMin(&prevsets[x])));
			maxs.erase(maxs.find(getMax(&prevsets[x])));
			mins.erase(mins.find(getMin(&prevsets[g[x]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[x]])));
			prevsets[g[x]].second.erase(prevsets[g[x]].second.find(getValue(x) - prevsets[g[x]].first));
			prevsets[x].first -= t[x] / (long long)(d[x] + 2);
			d[x]--;
			prevsets[x].first += t[x] / (long long)(d[x] + 2);
			prevsets[g[x]].second.insert(getValue(x) - prevsets[g[x]].first);
			mins.insert(getMin(&prevsets[x]));
			maxs.insert(getMax(&prevsets[x]));
			mins.insert(getMin(&prevsets[g[x]]));
			maxs.insert(getMax(&prevsets[g[x]]));

			//printf("OK 4\n");

			mins.erase(mins.find(getMin(&prevsets[y])));
			maxs.erase(maxs.find(getMax(&prevsets[y])));
			mins.erase(mins.find(getMin(&prevsets[g[y]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[y]])));
			prevsets[g[y]].second.erase(prevsets[g[y]].second.find(getValue(y) - prevsets[g[y]].first));
			prevsets[y].first -= t[y] / (long long)(d[y] + 2);
			d[y]++;
			prevsets[y].first += t[y] / (long long)(d[y] + 2);
			prevsets[g[y]].second.insert(getValue(y) - prevsets[g[y]].first);
			mins.insert(getMin(&prevsets[y]));
			maxs.insert(getMax(&prevsets[y]));
			mins.insert(getMin(&prevsets[g[y]]));
			maxs.insert(getMax(&prevsets[g[y]]));

			//printf("OK 5\n");

			mins.erase(mins.find(getMin(&prevsets[g[x]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[x]])));
			prevsets[g[x]].second.erase(prevsets[g[x]].second.find(getValue(x) - prevsets[g[x]].first));
			prevsum[x] -= t[v] / (long long)(d[v] + 2);
			prevsets[g[x]].second.insert(getValue(x) - prevsets[g[x]].first);
			mins.insert(getMin(&prevsets[g[x]]));
			maxs.insert(getMax(&prevsets[g[x]]));

			//printf("OK 6\n");

			mins.erase(mins.find(getMin(&prevsets[g[y]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[y]])));
			prevsets[g[y]].second.erase(prevsets[g[y]].second.find(getValue(y) - prevsets[g[y]].first));
			prevsum[y] += t[v] / (long long)(d[v] + 2);
			prevsets[g[y]].second.insert(getValue(y) - prevsets[g[y]].first);
			mins.insert(getMin(&prevsets[g[y]]));
			maxs.insert(getMax(&prevsets[g[y]]));

			//printf("OK 7\n");

			mins.erase(mins.find(getMin(&prevsets[g[g[x]]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[g[x]]])));
			prevsets[g[g[x]]].second.erase(prevsets[g[g[x]]].second.find(getValue(g[x]) - prevsets[g[g[x]]].first));
			prevsum[g[x]] += t[x] / (long long)(d[x] + 2);
			prevsets[g[g[x]]].second.insert(getValue(g[x]) - prevsets[g[g[x]]].first);
			mins.insert(getMin(&prevsets[g[g[x]]]));
			maxs.insert(getMax(&prevsets[g[g[x]]]));

			//printf("OK 8\n");

			mins.erase(mins.find(getMin(&prevsets[g[g[y]]])));
			maxs.erase(maxs.find(getMax(&prevsets[g[g[y]]])));
			prevsets[g[g[y]]].second.erase(prevsets[g[g[y]]].second.find(getValue(g[y]) - prevsets[g[g[y]]].first));
			prevsum[g[y]] += t[y] / (long long)(d[y] + 2);
			prevsets[g[g[y]]].second.insert(getValue(g[y]) - prevsets[g[g[y]]].first);
			mins.insert(getMin(&prevsets[g[g[y]]]));
			maxs.insert(getMax(&prevsets[g[g[y]]]));

			//printf("OK 9\n");
		}
		else if (T == 2)
		{
			int ind;
			scanf("%d",&ind);
			ind--;
			printf("%I64i\n",getValue(ind));
		}
		else
		{
			long long mn = *(mins.begin());
			long long mx = *(maxs.rbegin());
			printf("%I64i %I64i\n",mn,mx);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 300010
using namespace std;
typedef long long ll;
inline ll read ()
{
	ll s=0,w=1;
	char ch=getchar ();
	while (ch<'0'||ch>'9'){if (ch=='-') w=-1;ch=getchar ();}
	while ('0'<=ch&&ch<='9') s=(s<<1)+(s<<3)+(ch^48),ch=getchar ();
	return s*w;
}
int n,q;
ll A[MAXN],B[MAXN],C[MAXN],D[MAXN],E[MAXN];
multiset<ll>S_Max,S_Min;
multiset<ll>S[MAXN];
int main()
{
	n=read (),q=read ();
	for (register int i=1;i<=n;i++) B[i]=read ();
	for (register int i=1;i<=n;i++) A[i]=read (),D[i]+=2,D[A[i]]++;
	for (register int i=1;i<=n;i++) E[i]=B[i]/D[i];
	for (register int i=1;i<=n;i++) C[A[i]]+=E[i];
	for (register int i=1;i<=n;i++) S[A[i]].insert (B[i]-D[i]*E[i]+E[i]+C[i]);
	for (register int i=1;i<=n;i++)
		if (!S[i].empty ())
		{
			S_Max.insert (*S[i].rbegin ()+E[i]);
			S_Min.insert (*S[i].begin ()+E[i]);
		}
	while (q--)
	{
		int opt=read ();
		if (opt==1)
		{
			int x=read (),y=read (),fa=A[x];
			S_Max.erase (S_Max.find (*S[fa].rbegin ()+E[fa]));
			S_Min.erase (S_Min.find (*S[fa].begin ()+E[fa]));
			S[fa].erase (S[fa].find (B[x]-D[x]*E[x]+E[x]+C[x]));
			S_Max.erase (S_Max.find (*S[A[fa]].rbegin ()+E[A[fa]]));
			S_Min.erase (S_Min.find (*S[A[fa]].begin ()+E[A[fa]]));
			S[A[fa]].erase (S[A[fa]].find (B[fa]-D[fa]*E[fa]+E[fa]+C[fa]));

			S_Max.erase (S_Max.find (*S[A[A[fa]]].rbegin ()+E[A[A[fa]]]));
			S_Min.erase (S_Min.find (*S[A[A[fa]]].begin ()+E[A[A[fa]]]));
			S[A[A[fa]]].erase (S[A[A[fa]]].find (B[A[fa]]-D[A[fa]]*E[A[fa]]+E[A[fa]]+C[A[fa]]));

			C[A[fa]]-=E[fa];
			D[fa]--,E[fa]=B[fa]/D[fa],C[fa]-=E[x];
			C[A[fa]]+=E[fa];
			S[A[A[fa]]].insert (B[A[fa]]-D[A[fa]]*E[A[fa]]+E[A[fa]]+C[A[fa]]);
			S_Max.insert (*S[A[A[fa]]].rbegin ()+E[A[A[fa]]]);
			S_Min.insert (*S[A[A[fa]]].begin ()+E[A[A[fa]]]);

			S[A[fa]].insert (B[fa]-D[fa]*E[fa]+E[fa]+C[fa]);
			S_Max.insert (*S[A[fa]].rbegin ()+E[A[fa]]);
			S_Min.insert (*S[A[fa]].begin ()+E[A[fa]]);
			if (!S[fa].empty ())
			{
				S_Max.insert (*S[fa].rbegin ()+E[fa]);
				S_Min.insert (*S[fa].begin ()+E[fa]);
			}

			if (!S[y].empty ())
			{
				S_Max.erase (S_Max.find (*S[y].rbegin ()+E[y]));
				S_Min.erase (S_Min.find (*S[y].begin ()+E[y]));
			}
			S[y].insert (B[x]-D[x]*E[x]+E[x]+C[x]);
			S_Max.erase (S_Max.find (*S[A[y]].rbegin ()+E[A[y]]));
			S_Min.erase (S_Min.find (*S[A[y]].begin ()+E[A[y]]));
			S[A[y]].erase (S[A[y]].find (B[y]-D[y]*E[y]+E[y]+C[y]));

			S_Max.erase (S_Max.find (*S[A[A[y]]].rbegin ()+E[A[A[y]]]));
			S_Min.erase (S_Min.find (*S[A[A[y]]].begin ()+E[A[A[y]]]));
			S[A[A[y]]].erase (S[A[A[y]]].find (B[A[y]]-D[A[y]]*E[A[y]]+E[A[y]]+C[A[y]]));

			C[A[y]]-=E[y];
			D[y]++,E[y]=B[y]/D[y],C[y]+=E[x];
			C[A[y]]+=E[y];

			S[A[A[y]]].insert (B[A[y]]-D[A[y]]*E[A[y]]+E[A[y]]+C[A[y]]);
			S_Max.insert (*S[A[A[y]]].rbegin ()+E[A[A[y]]]);
			S_Min.insert (*S[A[A[y]]].begin ()+E[A[A[y]]]);

			S[A[y]].insert (B[y]-D[y]*E[y]+E[y]+C[y]);
			S_Max.insert (*S[A[y]].rbegin ()+E[A[y]]);
			S_Min.insert (*S[A[y]].begin ()+E[A[y]]);

			S_Max.insert (*S[y].rbegin ()+E[y]);
			S_Min.insert (*S[y].begin ()+E[y]);
			A[x]=y;
		}
		else if (opt==2)
		{
			int x=read ();
			printf ("%lld\n",B[x]-D[x]*E[x]+E[x]+C[x]+E[A[x]]);
		}
		else printf ("%lld %lld\n",*S_Min.begin (),*S_Max.rbegin ());
	}
	return 0;
}


#include<bits/stdc++.h>
#define MAXN 110000
using namespace std;
inline long long read()
{
	long long s = 0,w=1;char ch = getchar();
	while(ch<'0'||ch>'9'){if(ch == '-')w=-1;ch = getchar();}
	while(ch>='0'&&ch<='9')s = (s << 1) + (s << 3) + ch -'0',ch = getchar();
	return s * w;
}
int n,Q,d[MAXN],f[MAXN];
long long b[MAXN],c[MAXN],e[MAXN],opt[MAXN];
multiset<long long> ans_min,ans_max,son[MAXN];
inline void Del(int u)
{
	if(!son[u].empty())
		ans_min.erase(ans_min.find(*(son[u].begin())+opt[u])),
		ans_max.erase(ans_max.find(*(son[u].rbegin())+opt[u]));
}
inline void Ins(int u)
{
	if(!son[u].empty())
		ans_min.insert(*(son[u].begin())+opt[u]),ans_max.insert(*(son[u].rbegin())+opt[u]);
}
inline void Change(int u,int num,int x)
{
	int fa = f[u],gf = f[f[u]];
	Del(u),Del(fa),Del(gf);
	son[fa].erase(son[fa].find(c[u]));
	son[gf].erase(son[gf].find(c[fa]));
	long long tmpe = e[u];
	c[u] += d[u] * e[u] - e[u];
	d[u] = d[u] + num;
	e[u] = b[u] / d[u];
	c[fa] += e[u]-tmpe;
	c[u] -= d[u] * e[u] - e[u] - e[x] * num;
	son[gf].insert(c[fa]),son[fa].insert(c[u]);
	opt[u] += e[u] - tmpe;
	Ins(fa),Ins(gf);
}
int main()
{
	n = read(),Q = read();
	for(int i = 1;i<=n;++i) b[i] = read(),d[i]+=2;
	for(int i = 1;i<=n;++i) f[i] = read(),d[f[i]]++;
	for(int i = 1;i<=n;++i) e[i] = b[i] / d[i],c[f[i]] += e[i];
	for(int i = 1;i<=n;++i) c[i] += b[i]-d[i]*e[i]+e[f[i]]+e[i],son[f[i]].insert(c[i]);
	for(int i = 1;i<=n;++i) opt[i] = 0,Ins(i);
	while(Q--)
	{
		int optt = read(),x,w;
		if(optt == 1)
		{
			x = read(),w = read();
			Change(f[x],-1,x);
			son[f[x]].erase(son[f[x]].find(c[x]));
			c[x] -= e[f[x]] - opt[f[x]];
			Ins(f[x]);
			Change(w,1,x);
			c[x] += e[w] - opt[w];
			son[w].insert(c[x]);
			f[x] = w;
			Ins(w);
		}
		else if(optt == 2) x = read(),printf("%lld\n",c[x]+opt[f[x]]);
		else printf("%lld %lld\n",*(ans_min.begin()),*(ans_max.rbegin()));
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false); cout.tie(nullptr);
    int n, m, a, b, c, d; cin >> n >> m >> a >> b >> c >> d;
    if(m < n + 1) cout << -1 << "\n";
    else {
        int mid;
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d) { mid = i; break; }
        cout << a << " " << d << " " << mid << " " << c << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d && i != mid) cout << i << " ";
        cout << b << "\n";
        cout << c << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d && i != mid) cout << i << " ";
        cout << b << " " << mid << " " << a << " " << d << "\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false); cout.tie(nullptr);
    int n, m, a, b, c, d; cin >> n >> m >> a >> b >> c >> d;
    if(m < n) cout << -1 << "\n";
    else {
        cout << a << " " << d << " " << c << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d) cout << i << " ";
        cout << b << "\n";
        cout << c << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d) cout << i << " ";
        cout << b << " " << a << " " << d << "\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false); cout.tie(nullptr);
    int n, m, a, b, c, d; cin >> n >> m >> a >> b >> c >> d;
    if(m < n) cout << -1 << "\n";
    else {
        cout << a << " " << c << " " << d << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d) cout << i << " ";
        cout << b << "\n";
        cout << d << " ";
        for (int i = 1; i <= n; ++i) if(i != a && i != b && i != c && i != d) cout << i << " ";
        cout << b << " " << a << " " << c << "\n";
    }
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
//#define int long long
long double pi = acos(-1);
LL QPow(LL a, LL b) {LL ans = 1; while (b) { if (b & 1)ans *= a; a = a * a; b >>= 1; }return ans;}
int arr[1002];
int ans[1002];
signed main()
{
	ifstream in("Text.txt");
	//ofstream out("SQL.txt");
	//freopen("looking.in", "r", stdin);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL n, m;
	LL k;
	int a, b, c, d;
	int t;
	//int n;
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	if (n+1 > m||n<5)
	{
		cout << -1 << endl;
	}
	else
	{
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			if (i != a && i != b && i != c && i != d)ans[cnt++] = i;
		cout << a << " " << c << " ";
		for (int i = 0; i < cnt; i++)cout << ans[i] << " ";
		cout << d << " " << b << endl;
		cout << c << " " << a << " ";
		for (int i = cnt-1; i >=0; i--)cout << ans[i] << " ";
		cout << b << " " << d << endl;
	}
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
//#define int long long
long double pi = acos(-1);
LL QPow(LL a, LL b) {LL ans = 1; while (b) { if (b & 1)ans *= a; a = a * a; b >>= 1; }return ans;}
int arr[1002];
int ans[1002];
signed main()
{
	ifstream in("Text.txt");
	//ofstream out("SQL.txt");
	//freopen("looking.in", "r", stdin);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL n, m;
	LL k;
	int a, b, c, d;
	int t;
	//int n;
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	if (n > m)
	{
		cout << -1 << endl;
	}
	else
	{
		//cout << a << " " << c << " " << d << " ";
		int cnt = 0;
		ans[cnt++] = a;
		ans[cnt++] = c;
		ans[cnt++] = d;
		for (int i = 1; i <= n; i++)
		{
			if (i != a && i != b && i != c && i != d)ans[cnt++]=i;
		}

		ans[cnt++] = b;
		for (int i = 0; i < cnt; i++)cout << ans[i] << " ";
		cout << endl;
		cout << ans[1] << " " << ans[0] << " ";
		for (int i = cnt - 1; i >= 2; i--)cout << ans[i] << " ";
	}
//	system("pause");
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
//#define int long long
long double pi = acos(-1);
LL QPow(LL a, LL b) {LL ans = 1; while (b) { if (b & 1)ans *= a; a = a * a; b >>= 1; }return ans;}
int arr[1002];
int ans[1002];
signed main()
{
	ifstream in("Text.txt");
	//ofstream out("SQL.txt");
	//freopen("looking.in", "r", stdin);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL n, m;
	LL k;
	int a, b, c, d;
	int t;
	//int n;
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	if (n+3 > m+1||n<7)
	{
		cout << -1 << endl;
	}
	else
	{
		int cnt = 0;
		ans[cnt++] = a;
		int flag = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i != a && i != b && i != c && i != d)
			{
				ans[cnt++] = i;
				flag = i;
				break;
			}
		}
		ans[cnt++] = c;
		int flag2 = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i != flag && i != a && i != b && i != c && i != d)
			{
				ans[cnt++] = i;
				flag2 = i;
				break;
			}
		}
		ans[cnt++] = d;
		int flag3 = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i!=flag2&&i != flag && i != a && i != b && i != c && i != d)
			{
				if(cnt+2<n)
				ans[cnt++] = i;
				else {
					flag3 = i;
					ans[cnt++] = flag3;
					break;
				}
			}
		}
		ans[cnt++] = b;
		for (int i = 0; i < cnt; i++)cout << ans[i] << " ";
		cout << endl;
		cout << c << " " << flag2 << " " << flag << " " << a << " " << flag3 << " " << b << " ";
		for (int i = cnt - 3; ans[i] != d; i--)
		{
			cout << ans[i] << " ";
		}
		cout << d << endl;
	}
//	system("pause");
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<string>
#include<string.h>
#include<fstream>
#include<stack>
#include<iomanip>
#include<bitset>
#include<cmath>
#include<locale>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
#define lson rt<<1
#define rson rt<<1|1
#define mid (l+r)>>1
#define mes(a) memset(a,0,sizeof a)
//#define int long long
long double pi = acos(-1);
LL QPow(LL a, LL b) {LL ans = 1; while (b) { if (b & 1)ans *= a; a = a * a; b >>= 1; }return ans;}
int arr[1002];
int ans[1002];
signed main()
{
	ifstream in("Text.txt");
	//ofstream out("SQL.txt");
	//freopen("looking.in", "r", stdin);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL n, m;
	LL k;
	int a, b, c, d;
	int t;
	//int n;
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	if (n > m+1||n<7)
	{
		cout << -1 << endl;
	}
	else
	{
		int cnt = 0;
		ans[cnt++] = a;
		int flag = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i != a && i != b && i != c && i != d)
			{
				ans[cnt++] = i;
				flag = i;
				break;
			}
		}
		ans[cnt++] = c;
		int flag2 = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i != flag && i != a && i != b && i != c && i != d)
			{
				ans[cnt++] = i;
				flag2 = i;
				break;
			}
		}
		ans[cnt++] = d;
		int flag3 = 0;
		for (int i = 1; i <= n; i++)
		{
			if (i!=flag2&&i != flag && i != a && i != b && i != c && i != d)
			{
				if(cnt+2<n)
				ans[cnt++] = i;
				else {
					flag3 = i;
					ans[cnt++] = flag3;
					break;
				}
			}
		}
		ans[cnt++] = b;
		for (int i = 0; i < cnt; i++)cout << ans[i] << " ";
		cout << endl;
		cout << c << " " << flag2 << " " << flag << " " << a << " " << flag3 << " " << b << " ";
		for (int i = cnt - 3; ans[i] != d; i--)
		{
			cout << ans[i] << " ";
		}
		cout << d << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if (n < 5 || k < n + 1) {
        cout << -1 << endl;
    } else {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        vector<ll> v;
        for (ll i = 1; i <= n; i++) {
            if (i != a && i != b && i != c && i != d) {
                v.push_back(i);
            }
        }
        cout << a << " ";
        cout << c << " ";
        for (ll i : v) {
            cout << i << " ";
        }
        cout << d << " ";
        cout << b << " ";
        cout << endl;
        cout << c << " ";
        cout << a << " ";
        for (ll i : v) {
            cout << i << " ";
        }
        cout << b << " ";
        cout << d << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if (n < 7 || k < n + 3) {
        cout << -1 << endl;
    } else {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        vector<ll> v;
        for (ll i = 1; i <= n; i++) {
            if (i != a && i != b && i != c && i != d) {
                v.push_back(i);
            }
        }
        cout << a << " ";
        cout << v.front() << " ";
        cout << c << " ";
        for (ll i : v) {
            if (i != v.front() && i != v.back()) {
                cout << i << " ";
            }
        }
        cout << d << " ";
        cout << v.back() << " ";
        cout << b << " ";
        cout << endl;
        cout << c << " ";
        cout << v.front() << " ";
        cout << a << " ";
        for (ll i : v) {
            if (i != v.front() && i != v.back()) {
                cout << i << " ";
            }
        }
        cout << b << " ";
        cout << v.back() << " ";
        cout << d << " ";
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    if (k == n - 1) {
        cout << -1 << endl;
    } else {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        vector<ll> v{b, a, d, c};
        for (ll i = 1; i <= n; i++) {
            if (i != a && i != b && i != c && i != d) {
                v.push_back(i);
            }
        }
        rotate(v.begin(), v.begin() + 1, v.end());
        for (ll i : v) {
            cout << i << " ";
        }
        cout << endl;
        rotate(v.begin(), v.begin() + 2, v.end());
        for (ll i : v) {
            cout << i << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0) , cout.tie(0);
  int n , k;
  cin >> n >> k;
  int a , b , c , d;
  cin >> a >> b >> c >> d;
  if (n <= 4 || k <= n) {
    cout << -1 << '\n';
    return 0;
  }
  for (int go = 1; go <= 2; go++) {
    cout << a << " " << c << " ";
    for (int i = 1; i <= n; i++) {
      if (i != a && i != b && i != c && i != d) {
        cout << i << " ";
      }
    }
    cout << d << " " << b << '\n';
    swap(a , c);
    swap(b , d);
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,k,a,b,c,d;
    cin>>n>>k>>a>>b>>c>>d;
    vector<ll> v;
    for(ll i=1;i<=n;i++)
    if(i!=a&&i!=b&&i!=c&&i!=d)
    v.push_back(i);
    if(k<=n||n==4)
    cout<<-1;
    else{
        cout<<a<<" "<<c<<" ";
        for(ll i=0;i<v.size();i++)
        cout<<v[i]<<" ";
        cout<<d<<" "<<b<<endl;
        cout<<c<<" "<<a<<" ";
        for(ll i=0;i<v.size();i++)
        cout<<v[i]<<" ";
        cout<<b<<" "<<d;
    }
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

int p = 1e9 + 7;

int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, k;
    cin>>n>>k;
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if (n==4||k<=n) {cout<<-1; return 0;}
    int x = 1;
    while (a==x||b==x||c==x||d==x) x++;
    cout<<a<<' '<<d<<' '<<x<<' '<<c<<' ';
    for (int i = 1; i<=n; i++) if (i!=a&&i!=b&&i!=c&&i!=d&&i!=x) cout<<i<<' ';
    cout<<b<<endl;
    cout<<c<<' ';
    for (int i = 1; i<=n; i++) if (i!=a&&i!=b&&i!=c&&i!=d&&i!=x) cout<<i<<' ';
    cout<<b<<' '<<x<<' '<<a<<' '<<d<<endl;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

int p = 1e9 + 7;

int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, k;
    cin>>n>>k;
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if (k<n) {cout<<-1; return 0;}
    cout<<a<<' '<<d<<' '<<c<<' ';
    for (int i = 1; i<=n; i++) if (i!=a&&i!=b&&i!=c&&i!=d) cout<<i<<' ';
    cout<<b<<endl;
    cout<<c<<' ';
    for (int i = 1; i<=n; i++) if (i!=a&&i!=b&&i!=c&&i!=d) cout<<i<<' ';
    cout<<b<<' '<<a<<' '<<d<<endl;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(auto &a)
{
    for (auto s: a) cout<<s<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

int p = 1e9 + 7;

int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    ll s = (a+b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(string s)
{
int n = s.length();
vector<int> z(n);
int L = 0, R = 0;
for (int i = 1; i < n; i++) {
  if (i > R) {
    L = R = i;
    while (R < n && s[R-L] == s[R]) R++;
    z[i] = R-L; R--;
  } else {
    int k = i-L;
    if (z[k] < R-i+1) z[i] = z[k];
    else {
      L = i;
      while (R < n && s[R-L] == s[R]) R++;
      z[i] = R-L; R--;
    }
  }
}
return z;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, k;
    cin>>n>>k;
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if (k<n) {cout<<-1; return 0;}
    cout<<a<<' '<<d<<' '<<c<<' ';
    for (int i = 0; i<n; i++) if (i!=a&&i!=b&&i!=c&&i!=d) cout<<i<<' ';
    cout<<b<<endl;
    cout<<c<<' ';
    for (int i = 0; i<n; i++) if (i!=a&&i!=b&&i!=c&&i!=d) cout<<i<<' ';
    cout<<b<<' '<<a<<' '<<d<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

	ll n,k;
	cin>>n>>k;
	ll a,b ,c ,d;
	cin>>a>>b>>c>>d;
	if(k==n-1)
	{
		cout<<-1;return 0;
		 }
	map<ll,ll>mp;
	mp[a]++;mp[b]++;
	mp[c]++;mp[d]++;

	vector<ll>v;
	v.push_back(a);v.push_back(c);v.push_back(d);

	for(ll i=1;i<=n;i++)
	{
		if(mp[i]==0&&i!=b)
		{
			v.push_back(i);
			mp[i]++;
		}
	}
	v.push_back(b);

	for(ll i=0;i<n;i++)
	{
		cout<<v[i]<<" ";
	}
	cout<<endl;
	for(ll i=1;i>=0;i--)
	{
		cout<<v[i]<<" ";
	}
	for(ll i=n-1;i>1;i--)
	cout<<v[i]<<" ";
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    map<ll,ll>mp;
    ll n,k;
    cin>>n>>k;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    if(n==4||(k-(n-1)<2))
    {
    	cout<<"-1";return 0;
	}

	vector<ll>v;
	v.push_back(a);mp[a]++;
	v.push_back(c);mp[c]++;

	for(ll i=1;i<=n;i++)
	{
		if(mp[i]==0&&i!=b&&i!=d)
		{
			v.push_back(i);
			mp[i]++;
		}
	}
	v.push_back(d);v.push_back(b);
	for(ll i=0;i<v.size();i++)
	{
		cout<<v[i]<<" ";
	}
	cout<<endl;
	for(ll i=1;i>=0;i--)
	{
		cout<<v[i]<<" ";
	}
	for(ll i=2;i<v.size()-2;i++)
	{
		cout<<v[i]<<" ";
	}
	cout<<v[n-1]<<" "<<v[n-2];
}


#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <unordered_set>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <stack>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

#define int long long
#define eb emplace_back
#define pb push_back
#define ld long double
#define f first
#define s second
#define deb(a) cerr << #a << " = " << a << '\n';
#define fast() { \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0); \
    cout << fixed << setprecision(15); \
    cerr << fixed << setprecision(11); \
}

const int INF = 1e9 + 7;
const ld EPS = 1e-10;
const int MAXI = 20000;
const int MOD = 1e8;
const int MAXST = 2000000;
const int P = 62;
const ld PI = 3.14159265358979323;
int n, k;
int dp[5001][5001], a[300000], d2[100000], used[3000000];
vector < int > ve1[300000], ve2[300000];
vector < set < int > > q;

void kek (int a, int b, int c, int d){
	cout << a << ' ' << c << ' ';
	for (int i = 0; i < n; i++){
		if (i + 1 != a && i + 1 != b && i + 1 != c && i + 1 != d)
			cout << i + 1 << ' ';
	}
	cout << d << ' ' << b << '\n';
}

signed main() {
#ifdef _LOCAL
    clock_t tStart = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
   /* freopen("cipher.in", "r", stdin);
    freopen("cipher.out", "w", stdout);*/
    fast();
   	cin >> n >> k;
   	int a, b, c, d;
   	cin >> a >> b >> c >> d;
   	if (n == 4)
   		return cout << -1, 0;
   	else if (n >= k)
   		return cout << -1, 0;
   	kek(a, b, c, d);
   	kek(c, d, a, b);
#ifdef _LOCAL
    cerr << "Runtime: " << (ld)(clock() - tStart) / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod) {
    x+=y; if (x>=mod) x-=mod;
}
void et() {
    puts("-1"); exit(0);
}

int a,b,c,d,T;
bool ok(int x) {
    return x!=a &&  x!=b && x!=c && x!=d &&  x!=T;
}
void fmain() {
    scanf("%d%d",&n, &k);
    if (k==n-1 || n==4) et();
    else {
        cin>>a>>b>>c>>d;
        REQ(i,n) if (ok(i)) {
            T=i; break;
        }
        printf("%d ", a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d %d %d %d\n",d,T,c,b);
        printf("%d %d %d %d ",c,b,T,a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d\n",d);
    }
}
int main() {

    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod) {
    x+=y; if (x>=mod) x-=mod;
}
void et() {
    puts("-1"); exit(0);
}

int a,b,c,d;
bool ok(int x) {
    return x!=a &&  x!=b && x!=c && x!=d;
}
void fmain() {
    scanf("%d%d",&n, &k);
    if (k==n-1) et();
    else {
        cin>>a>>b>>c>>d;
        printf("%d ", a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d %d %d\n",d,b,c);
        printf("%d %d ",c,a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d %d\n",d,b);
    }
}
int main() {

    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod) {
    x+=y; if (x>=mod) x-=mod;
}
void et() {
    puts("-1"); exit(0);
}

int a,b,c,d,T;
bool ok(int x) {
    return x!=a &&  x!=b && x!=c && x!=d &&  x!=T;
}
void fmain() {
    scanf("%d%d",&n, &k);
    if (k<=n || n==4) et();
    else {
        cin>>a>>b>>c>>d;
        REQ(i,n) if (ok(i)) {
            T=i; break;
        }
        printf("%d ", a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d %d %d %d\n",d,T,c,b);
        printf("%d %d %d %d ",c,b,T,a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d\n",d);
    }
}
int main() {

    fmain();
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef long double ld;
typedef unsigned int uint;
#define MAX 105
bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod) {
    x+=y; if (x>=mod) x-=mod;
}
void et() {
    puts("-1"); exit(0);
}

int a,b,c,d;
bool ok(int x) {
    return x!=a &&  x!=b && x!=c && x!=d;
}
void fmain() {
    scanf("%d%d",&n, &k);
    if (k==n-1) et();
    else {
        cin>>a>>b>>c>>d;
        printf("%d ", a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d %d %d\n",d,c,b);
        printf("%d %d %d ",c,b,a);
        REQ(i,n) if (ok(i)) printf("%d ", i);
        printf("%d\n", d);
    }
}
int main() {

    fmain();
    return 0;
}


#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric>
#include<unordered_map>
using namespace std;
#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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int P[1002][1002];
int path = 0;

vector<int>find(int a , int b , int n){
  vector<int>ans;
  if(b - a + 1 == n){
    for(int i=a;i<=b;i++){
      ans.push_back(i);
    }
    return ans;
  }
  else{
    if(a == 1){
      if(P[b-1][n] == 0){
        path++;
        P[b-1][n] = P[n][b-1] = 1;
      }
      for(int i=a;i<b;i++) ans.push_back(i);
      for(int i=n;i>=b;i--) ans.push_back(i);
      return ans;
    }
    else{
      int rstep = n - (b - a) + 1;
      int need = n - rstep;
      int cur = a;
      dg3(rstep , need , cur);
      ans.push_back(cur);
      for(int i=0;i<need;i++){
        ++cur;
        ans.push_back(cur);
      }
      if(P[cur][a-1] == 0){
        path++;
        P[cur][a-1] = P[a-1][cur] = 0;
      }

      cur = a-1;
      for(int i=0;i<rstep-1;i++){
        int x = cur - i;
        if(x <= 0) x += n;
        ans.push_back(x);
      }

    }
  }
  return ans;
}
void _p(vector<int>&a , int n){
  for(int i=0;i<n;i++){
    cout << a[i] <<" ";
  }
  cout << '\n';
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n , k;
  cin >> n >> k;
  int a, b , c , d;
  cin >> a >> b >> c >> d;
  int M1 = min(a,b) , M2 = max(a,b);
  int N1 = min(c , d) , N2 = max(c,d);

   path = n - 1;

  if( (M2 - M1 + 1 < n) || (N2 - N1 + 1) < n){
    path++;
  }

  vector<int>p1 = find(M1 , M2 , n);
  vector<int>p2 = find(N1 , N2 , n);
  if(path > k){
    cout << -1 << '\n';
    return 0;
  }
  if(a > b) reverse(p1.begin() , p1.end());
  if(c > d) reverse(p2.begin() , p2.end());
  dg(p1);
  dg(p2);
  _p(p1 , n);
  _p(p2 , n);
}


#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric>
#include<unordered_map>
using namespace std;
#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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int P[1002][1002];
int path = 0;

vector<int>find(int a , int b , int n){
  vector<int>ans;
  if(b - a + 1 == n){
    for(int i=a;i<=b;i++){
      ans.push_back(i);
    }
    return ans;
  }
  else{
    if(a == 1){
      if(P[b-1][n] == 0){
        path++;
        P[b-1][n] = P[n][b-1] = 1;
      }
      for(int i=a;i<b;i++) ans.push_back(i);
      for(int i=n;i>=b;i--) ans.push_back(i);
      return ans;
    }
    else{
      int rstep = n - (b - a) + 1;
      int need = n - rstep;
      int cur = a;
      dg3(rstep , need , cur);
      ans.push_back(cur);
      for(int i=0;i<need;i++){
        ++cur;
        ans.push_back(cur);
      }
      if(P[cur][a-1] == 0){
        path++;
        P[cur][a-1] = P[a-1][cur] = 0;
      }

      cur = a-1;
      for(int i=0;i<rstep-1;i++){
        int x = cur - i;
        if(x <= 0) x += n;
        ans.push_back(x);
      }

    }
  }
  return ans;
}
void _p(vector<int>&a , int n){
  for(int i=0;i<n;i++){
    cout << a[i] <<" ";
  }
  cout << '\n';
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n , k;
  cin >> n >> k;
  int a, b , c , d;
  cin >> a >> b >> c >> d;
  int M1 = min(a,b) , M2 = max(a,b);
  int N1 = min(c , d) , N2 = max(c,d);

   path = n - 1;

  if( (M2 - M1 + 1 < n) || (N2 - N1 + 1) < n){
    path++;
  }

  vector<int>p1 = find(M1 , M2 , n);
  vector<int>p2 = find(N1 , N2 , n);
  if(path > k){
    cout << -1 << '\n';
    return 0;
  }

  dg(p1);
  dg(p2);
  _p(p1 , n);
  _p(p2 , n);
}


#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric>
#include<unordered_map>
using namespace std;
#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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
void _p(vector<int>&a){
  for(int i=0;i<sz(a);i++){
    cout << a[i] <<" ";
  }
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int n , k;
  cin >> n >> k;
  int a, b , c , d;
  cin >> a >> b >> c >> d;
  if(n == 4 || k <= n){
    cout << -1 << '\n';
    return 0;
  }

  vector<int>Mid;
  for(int i=1;i<=n;i++){
    if(i != a && i != b && i != c && i!= d){
      Mid.push_back(i);
    }
  }

  cout << a << " " << c <<" ";
  _p(Mid); cout << d <<" " << b << '\n';

  cout << c <<" " << a <<" ";
  _p(Mid);
  cout << b <<" " << d << '\n';
}


//bluishgreen
#include <bits/stdc++.h>
#include <sstream>
#include<ctime>
using namespace std;
#define REP(i,a,b) for(i=a;i<b;i++)
#define getarr(a,n) for(i=0;i<n;i++){cin>>a[i];}
#define disparr(a,n) for(i=0;i<n;i++){cout<<a[i];}cout<<"\n";
#define disparrs(a,n) for(i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";
#define disparrl(a,n) for(i=0;i<n;i++){cout<<a[i]<<"\n";}cout<<"\n";
#define mem0(a) memset(a,0,sizeof(a));
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define F first
#define S second
#define nu 100001
#define M 1000000007
#define mul(x,y) ((ll)(x)*(y))%M
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 0x3f3f3f3f
int MOD(int a, int b)
{
    if(a>b)
    return a-b;
    else
    return b-a;
}
ll max3(ll a,ll b,ll c)
{
    return max(c,max(a,b));
}
ll power(ll x,ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll max(ll a,ll b)
{
    return (a>b)?a:b;
}
ll min(ll a,ll b)
{
    return (a<b)?a:b;
}
ll gcd(ll a,ll b)
{
    if(b==1)
    return 1;
    else if(a%b==0)
    return b;
    else
    return gcd(b,a%b);
}
int level[1001];
bool vis[1001];
vi adj[1001];
map<pii,bool> m;
void bfs(int s)
{
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        vis[x] = true;
        vi::iterator i;
        REP(i,adj[x].begin(),adj[x].end())
        {
            if(!vis[*i])
            {
                level[*i] = level[x] + 1;
                vis[*i] = true;
                q.push(*i);
            }
        }
    }
}
int main()
{
    fastio;
    int n,k,a,b,c,d,i,j,l;
    cin>>n>>k>>a>>b>>c>>d;
    if((n==4)||(k<n+1))
    {
        cout<<"-1\n";
        return 0;
    }
    map<int,bool> m;
    vi v;
    v.pb(a);
    v.pb(c);
    m[a] = true;
    m[b] = true;
    m[c] = true;
    m[d] = true;
    int ctr = 0;
    int t1,t2,i1,i2;
    REP(i,1,n+1)
    {
        if(!m[i])
        {
            ctr++;
            if(ctr == 1)
            {
                t1 = i;
                i1 = v.size();
            }
            if(ctr == n-4)
            {
                t2 = i;
                i2 = v.size();
            }
            v.pb(i);
            m[i] = true;
        }
    }
    v.pb(d);
    v.pb(b);
    disparrs(v,v.size())
    cout<<c<<" "<<a<<" ";
    REP(i,i1,i2+1)
    {
        cout<<v[i]<<" ";
    }
    cout<<b<<" "<<d<<"\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const long long mod=1e9+7;
typedef complex<double> cd;
typedef long long int lli;
typedef long int li;
#define For(i,n) for(long long int i=0;i<n;i++)
#define Ff(i,a,b) for(long long int i = a; i < b; i+=1)
#define Fb(i,a,b) for(long long int i = a; i>=b; i-- )
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define pff(a,b) printf("%ld %ld", a, b)

typedef pair<long long int, long long int> pi;

bool sortinrev(const pair<int,int> &a,  const pair<int,int> &b)    // Driver function to sort the vector elements by
{ 																	// first element of pair in descending order
	   return (a.first > b.first);
}

lli power(lli x, lli y, lli p)
{
	lli res = 1;
	x = x%p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x)%p;
		y = y>>1;
		x = (x*x)%p;
	}
	return res;
}

//char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

/*
lli binomialCoeff(int n, int k)
{
	lli C[k+1];
	memset(C, 0, sizeof(C));
	C[0] = 1;
	for (int i = 1; i <= n; i++)
	{
			for (int j = min(i, k); j > 0; j--)
			C[j] = (C[j] + C[j-1]);
	}
	return C[k];
}
*/
//priority_queue<pair<long int, long int> > pqq;                          //Maximum on top
//priority_queue<pi, vector<pi>, greater<pi> > pq;                        //Minimum on top

lli root (lli* Arr ,lli i)
{
	while(Arr[i] != i)
	{
		Arr[i] = Arr[Arr[i]] ;
		i = Arr[i];
	}
	return i;
}
void unin(lli* Arr,lli* size,lli A,lli B)
{
	lli root_A = root(Arr, A);
	lli root_B = root(Arr, B);
	if(root_A == root_B)
		return;
	else if(size[root_A] < size[root_B])
	{
		Arr[root_A] = Arr[root_B];
		size[root_B] += size[root_A];
	}
	else
	{
		Arr[root_B] = Arr[root_A];
		size[root_A] += size[root_B];
	}

}

lli gcd(lli a, lli b)
{
	if(b==0)
		return a;
	else
		return gcd(b, a%b);
}

int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

	lli n,k;
	cin>>n>>k;
	lli a,b,c,d;
	cin>>a>>b>>c>>d;
	if(n==4 || k<=n)
	{
		cout<<"-1";
		return 0;
	}
	cout<<a<<" "<<c<<" ";
	Ff(i, 1, n+1)
	{
		if(i!=a && i!=b && i!=c && i!=d)
			cout<<i<<" ";
	}
	cout<<d<<" "<<b<<endl;
	cout<<c<<" "<<a<<" ";
	Ff(i, 1, n+1)
	{
		if(i!=a && i!=b && i!=c && i!=d)
			cout<<i<<" ";
	}
	cout<<b<<" "<<d<<endl;

	return 0;
}


#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
*/

//#define double long double
#define int long long
#define f first
#define s second
#define pb push_back
#define eb emplace_back
//#define mp make_pair
#define pii pair <int, int>
#define fast() { \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout << fixed << setprecision(20); \
    cerr << fixed << setprecision(11); \
}

const int INF = 1e18 + 7;
const int N = 2e5 + 7;
const int MOD = 1e9 + 7;
const double Pi = 3.14159265358979323846;

signed main() {
    fast();
    int n, k;
    cin >> n >> k;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(n == 4 || k < n + 1)
        cout << -1 << '\n';
    else {
        cout << a << ' ' << c << ' ';
        for(int i = 1; i <= n; i++)
            if(i != a && i != b && i != c && i != d)
                cout << i << ' ';
        cout << d << ' ' << b << '\n';
        cout << c << ' ' << a << ' ';
        for(int i = 1; i <= n; i++)
            if(i != a && i != b && i != c && i != d)
                cout << i << ' ';
        cout << b << ' ' << d << '\n';
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS
    ll n, k;
    cin >> n >> k;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    if(n == 4 || k < n+1)
    {
        cout << -1 << endl;
        return 0;
    }
    ll i;
    deque<ll>q, q2;

    for(i = 1; i <= n; i++)
    {
        if(i == a || i == b || i == c || i == d)
        {
            continue;
        }
        q.push_back(i);
    }
    q.push_front(c);
    q.push_front(a);
    q.push_back(d);
    q.push_back(b);
    for(auto i:q)
    cout << i << " ";
    cout << endl;
    ll x = q.front();
    q.pop_front();
    q2.push_back(x);
    q2.push_front(q.front());
    q.pop_front();
    q2.push_back(q.front());
    q.pop_front();
    while(true)
    {
        x = q.front();
        q.pop_front();
        if(x == d)
        {
            q.push_front(x);
            break;
        }
        q2.push_back(x);
    }
    while(true)
    {
        x = q.back();
        q.pop_back();
        q2.push_back(x);
        if(x == d)
        break;
    }
    for(auto i:q2)
    cout << i << " ";
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS
    ll n, k;
    cin >> n >> k;
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    if(n == 4 || k < n+1)
    {
        cout << -1 << endl;
        return 0;
    }
    ll i;
    deque<ll>q, q2;

    for(i = 1; i <= n; i++)
    {
        if(i == a || i == b || i == c || i == d)
        {
            continue;
        }
        q.push_back(i);
    }
    q.push_front(c);
    q.push_front(a);
    q.push_back(d);
    q.push_back(b);
    for(auto i:q)
    cout << i << " ";
    cout << endl;
    ll x = q.front();
    q.pop_front();
    q2.push_back(x);
    q2.push_front(q.front());
    q.pop_front();
    while(true)
    {
        x = q.back();
        q.pop_back();
        if(x == d)
        {
            q.push_back(x);
            break;
        }
        q2.push_back(x);
    }
    while(true)
    {
        x = q.front();
        q.pop_front();
        q2.push_back(x);
        if(x == d)
        break;
    }
    for(auto i:q2)
    cout << i << " ";
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define endl '\n'
#define IO; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n,k;
    cin>>n>>k;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(n==4 || k<=n) cout<<-1<<endl;
    else{
        cout<<a<<" "<<c<<" ";
        for(int i=1;i<=n;i++)
        {
            if(i==a || i==b || i==c || i==d) continue;
            cout<<i<<" ";
        }
        cout<<d<<" "<<b<<endl;

        cout<<c<<" "<<a<<" ";
        for(int i=1;i<=n;i++)
        {
            if(i==a || i==b || i==c || i==d) continue;
            cout<<i<<" ";
        }
        cout<<b<<" "<<d<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define MAXN 100005
#define ll long long int

int main(){
    int n,k;
    cin>>n>>k;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(n==4 || n+1>k){
        cout<<"-1"<<"\n";
        return 0;
    }
    /*
    int r1=0,r2=0;
    if(a>b){
        int t=a;
        a=b;
        b=t;
        r1=1;
    }
    if(d>c){
        int t=c;
        c=d;
        d=t;
        r2=1;
    }*/
    int aux=0;
    for(int i=1;i<=n;i++){
        if(i!=a && i!=b && i!=c && i!=d){
            aux=i;
            break;
        }
    }
    vector<int> p1;
    p1.push_back(a);
    p1.push_back(c);
    p1.push_back(aux);
    p1.push_back(d);
    vector<int> rem_nodes;
    for(int i=1;i<=n;i++){
        if(i!=a && i!=b && i!=c && i!=d && i!=aux){
            p1.push_back(i);
            rem_nodes.push_back(i);
        }
    }
    p1.push_back(b);
    vector<int> p2;
    p2.push_back(c);
    p2.push_back(a);
    p2.push_back(aux);
    p2.push_back(b);
    for(int i=rem_nodes.size()-1;i>=0;i--){
        p2.push_back(rem_nodes[i]);
    }
    p2.push_back(d);
    //if(r1)reverse(p1.begin(),p1.end());
    //if(r2)reverse(p2.begin(),p2.end());
    //cout<<p1.size()<<"\n";
    for(int i=0;i<p1.size();i++)cout<<p1[i]<<" ";
    cout<<"\n";
    //cout<<p2.size()<<"\n";
    for(int i=0;i<p2.size();i++)cout<<p2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define MAXN 100005
#define ll long long int

int main(){
    int n,k;
    cin>>n>>k;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(n==4 || n+1>k){
        cout<<"-1"<<"\n";
        return 0;
    }
    int r1=0,r2=0;
    if(a>b){
        int t=a;
        a=b;
        b=t;
        r1=1;
    }
    if(d>c){
        int t=c;
        c=d;
        d=t;
        r2=1;
    }
    int aux=0;
    for(int i=1;i<=n;i++){
        if(i!=a && i!=b && i!=c && i!=d){
            aux=i;
            break;
        }
    }
    vector<int> p1;
    p1.push_back(a);
    p1.push_back(c);
    p1.push_back(aux);
    p1.push_back(d);
    vector<int> rem_nodes;
    for(int i=1;i<n;i++){
        if(i!=a && i!=b && i!=c && i!=d && i!=aux){
            p1.push_back(i);
            rem_nodes.push_back(i);
        }
    }
    p1.push_back(b);
    vector<int> p2;
    p2.push_back(c);
    p2.push_back(a);
    p2.push_back(aux);
    p2.push_back(b);
    for(int i=0;i<rem_nodes.size()+1;i++){
        p2.push_back(rem_nodes.back());
        rem_nodes.pop_back();
    }
    p2.push_back(d);
    if(r1)reverse(p1.begin(),p1.end());
    if(r2)reverse(p2.begin(),p2.end());
    for(int i=0;i<p1.size();i++)cout<<p1[i]<<" ";
    cout<<"\n";
    for(int i=0;i<p2.size();i++)cout<<p2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define MAXN 100005
#define ll long long int

int main(){
    int n,k;
    cin>>n>>k;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(n==4 || n+1>k){
        cout<<"-1"<<"\n";
        return 0;
    }
    int r1=0,r2=0;
    if(a>b){
        int t=a;
        a=b;
        b=t;
        r1=1;
    }
    if(d>c){
        int t=c;
        c=d;
        d=t;
        r2=1;
    }
    int aux=0;
    for(int i=1;i<=n;i++){
        if(i!=a && i!=b && i!=c && i!=d){
            aux=i;
            break;
        }
    }
    vector<int> p1;
    p1.push_back(a);
    p1.push_back(c);
    p1.push_back(aux);
    p1.push_back(d);
    vector<int> rem_nodes;
    for(int i=1;i<n;i++){
        if(i!=a && i!=b && i!=c && i!=d && i!=aux){
            p1.push_back(i);
            rem_nodes.push_back(i);
        }
    }
    p1.push_back(b);
    vector<int> p2;
    p2.push_back(c);
    p2.push_back(a);
    p2.push_back(aux);
    p2.push_back(b);
    for(int i=rem_nodes.size()-1;i>=0;i--){
        p2.push_back(rem_nodes[i]);
    }
    p2.push_back(d);
    if(r1)reverse(p1.begin(),p1.end());
    if(r2)reverse(p2.begin(),p2.end());
    for(int i=0;i<p1.size();i++)cout<<p1[i]<<" ";
    cout<<"\n";
    for(int i=0;i<p2.size();i++)cout<<p2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define MAXN 100005
#define ll long long int

int main(){
    int n,k;
    cin>>n>>k;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(n==4 || n+1>k){
        cout<<"-1"<<"\n";
        return 0;
    }
    /*
    int r1=0,r2=0;
    if(a>b){
        int t=a;
        a=b;
        b=t;
        r1=1;
    }
    if(d>c){
        int t=c;
        c=d;
        d=t;
        r2=1;
    }*/
    int aux=0;
    for(int i=1;i<=n;i++){
        if(i!=a && i!=b && i!=c && i!=d){
            aux=i;
            break;
        }
    }
    vector<int> p1;
    p1.push_back(a);
    p1.push_back(c);
    p1.push_back(aux);
    p1.push_back(d);
    vector<int> rem_nodes;
    for(int i=1;i<n;i++){
        if(i!=a && i!=b && i!=c && i!=d && i!=aux){
            p1.push_back(i);
            rem_nodes.push_back(i);
        }
    }
    p1.push_back(b);
    vector<int> p2;
    p2.push_back(c);
    p2.push_back(a);
    p2.push_back(aux);
    p2.push_back(b);
    for(int i=rem_nodes.size()-1;i>=0;i--){
        p2.push_back(rem_nodes[i]);
    }
    p2.push_back(d);
    //if(r1)reverse(p1.begin(),p1.end());
    //if(r2)reverse(p2.begin(),p2.end());
    for(int i=0;i<p1.size();i++)cout<<p1[i]<<" ";
    cout<<"\n";
    for(int i=0;i<p2.size();i++)cout<<p2[i]<<" ";
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int

using namespace std;

vector <int> A, B;

int main() {
    int n, k, a, b, c, d;
    cin >> n >> k >> a >> b >> c >> d;

    if(k < n + 1 || n < 5) {
        cout << -1 << endl;
    } else {
        int fl1 = 0, fl2 = 0;

        if(a > b) {
            swap(a, b);
            fl1 = 1;
        }

        if(c > d) {
            swap(c, d);
            fl2 = 1;
        }

        for(int i = 1; i <= n; i++) {
            if(i != a && i != b && i != c && i != d) {
                A.push_back(i);
            }
        }

        B.push_back(a); B.push_back(c); B.push_back(A[0]); B.push_back(d);
        for(int i = 1; i < A.size(); i++) {
            B.push_back(A[i]);
        }
        B.push_back(b);
        if(fl1) {
            reverse(B.begin(), B.end());
        }
        for(int i = 0; i < B.size(); i++) {
            cout << B[i] << " ";
        }
        cout << endl;
        B.clear();

        B.push_back(c); B.push_back(a); B.push_back(A[0]); B.push_back(b);
        for(int i = A.size() - 1; i > 0; i--) {
            B.push_back(A[i]);
        }
        B.push_back(d);
        if(fl2) {
            reverse(B.begin(), B.end());
        }
        for(int i = 0; i < B.size(); i++) {
            cout << B[i] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int

using namespace std;

vector <int> A;

int main() {
    int n, k, a, b, c, d;
    cin >> n >> k >> a >> b >> c >> d;

    if(k < n + 1 || n < 5) {
        cout << -1 << endl;
    } else {
        if(a > b) {
            swap(a, b);
        }
        if(c > d) {
            swap(c, d);
        }
        for(int i = 1; i <= n; i++) {
            if(i != a && i != b && i != c && i != d) {
                A.push_back(i);
            }
        }

        cout << a << " " << c << " " << A[0] << " " << d << " ";
        for(int i = 1; i < A.size(); i++) {
            cout << A[i] << " ";
        }
        cout << b << endl;

        cout << c << " " << a << " " << A[0] << " " << b << " ";
        for(int i = A.size() - 1; i > 0; i--) {
            cout << A[i] << " ";
        }
        cout << d << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	if(n < 5 || k < n + 1) {
		cout << -1 << '\n';
		return 0;
	}
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<int> rest;
	rest.reserve(n - 4);
	for(int i = 1; i <= n; i++) {
		if(i != a && i != b && i != c && i != d)
			rest.push_back(i);
	}

	cout << a << ' ' << c << ' ';
	for(int i = 0; i < rest.size(); i++) {
		cout << rest[i] << ' ';
	}
	cout << d << ' ' << b << '\n';

	cout << c << ' ' << a << ' ';
	for(int i = 0; i < rest.size(); i++) {
		cout << rest[i] << ' ';
	}
	cout << b << ' ' << d << '\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(1e3 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef double db;
typedef long double ld;
const int INF= int(1e9 + 7);
const ll MOD = ll(998'244'353);
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}
int used[MAXN], ans[MAXN];
int a, b, c, d;

void err() {
        cout << -1 << endl;
        exit(0);
}

void build(int n) {

        int x = 1;
        REPN(i, n - 2, 3) {

                if(used[x]) {
                        i--;
                        x++;
                        continue;
                }

                ans[i] = x++;
        }

}

void init(int ch, int n) {

        if(!ch)
                ans[1] = a, ans[2] = c, ans[n] = b, ans[n - 1] = d;
        else
                ans[1] = c, ans[2] = a, ans[n] = d, ans[n - 1] = b;
}

void pprint(int n) {

        REPN(i, n, 1)
                cout << ans[i] << " ";
        cout << endl;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n, k;
        cin >> n >> k >> a >> b >> c >> d;

        used[a] = 1;
        used[b] = 1;
        used[c] = 1;
        used[d] = 1;
        if(n > k)
                err();

        ans[1] = a, ans[2] = c, ans[n] = b, ans[n - 1] = d;
        if(n == 4) {

                init(0, n);
                build(n);
                pprint(n);

                init(1, n);
                build(n);
                pprint(n);
        }

        if(k < n + 1)
                err();

        init(0, n);
        build(n);
        pprint(n);

        init(1, n);
        build(n);
        pprint(n);

        return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN (int)(1e3 + 5)
#define MAXM (int)(1e2+5)
#define fr first
#define sd second
#define MP make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define M0(a) memset(a, 0, sizeof(a))
#define M1(a) memset(a, -1, sizeof(a))
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REPN(i,n,m) for(int i = m; i <= int(n); i++)
#define RREP(i,n) for(int i = int(n-1); i >= 0; i--)
#define RREPN(i, n, m) for(int i = n; i >= (int)m; i--)
typedef long long ll;
typedef double db;
typedef long double ld;
const int INF= int(1e9 + 7);
const ll MOD = ll(998'244'353);
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> ppii;
template<typename T, typename U> inline void AMIN(T &x, U y){ if(x > y) x = y;}
template<typename T, typename U> inline void AMAX(T &x, U y){ if(x < y) x = y;}
int used[MAXN], ans[MAXN];
int a, b, c, d;

void err() {
        cout << -1 << endl;
        exit(0);
}

void build(int n) {

        int x = 1;
        REPN(i, n - 2, 3) {

                if(used[x]) {
                        i--;
                        x++;
                        continue;
                }

                ans[i] = x++;
        }

}

void init(int ch, int n) {

        if(!ch)
                ans[1] = a, ans[2] = c, ans[n] = b, ans[n - 1] = d;
        else
                ans[1] = c, ans[2] = a, ans[n] = d, ans[n - 1] = b;
}

void pprint(int n) {

        REPN(i, n, 1)
                cout << ans[i] << " ";
        cout << endl;
}

int main() {
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n, k;
        cin >> n >> k >> a >> b >> c >> d;

        used[a] = 1;
        used[b] = 1;
        used[c] = 1;
        used[d] = 1;
        if(n > k)
                err();

        if(n == 4) {

                err();
        }

        if(k < n + 1)
                err();

        init(0, n);
        build(n);
        pprint(n);

        init(1, n);
        build(n);
        pprint(n);

        return 0;
}


/* aman36 - Aman Raj */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fast_io ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define F first
#define S second
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define forlp(k,x,n)  for (ll k = x; k <= n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
#define vi vector <int>
#define mem(x, v) memset(x, v, sizeof(x));
#define int ll
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

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

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif

ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

bool isPrime(int n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int M = 3000+5;
const int N = 3e5+5;
const int maxn = 1e5+5;

void solve() {

    int n, k;
    cin >> n >> k;

    int a, b, c, d; cin >> a >> b >> c >> d;

    vll v;
    for(int i=1; i<=n; i++) {
        if(i != a && i!= b && i!= c && i!=d) v.pb(i);
    }

    if(k <= n) {
        cout << -1 << endl;
        return;
    }

    cout << a << " ";
    cout << c << " ";
    for(auto x: v) cout << x << " ";
    cout << d << " ";
    cout << b << endl;

    cout << c << " ";
    cout << a << " ";
    for(auto x: v) cout << x << " ";
    cout << b << " ";
    cout << d << endl;

}

signed main() {
    fast_io;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int tc = 1;
    // cin >> tc;

    for(int i=1; i<=tc; i++) {
        // cout << "Case #" << i << ": " ;
        solve();
    }

    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}

// read the question correctly
// read code carefully
// corner cases // int vs ll // cin vs scanf // clear structures // maths
// check if max, min set to INT_MAX instead of INF
// check constraint


/* aman36 - Aman Raj */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fast_io ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define pii pair<int, int>
#define F first
#define S second
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define forlp(k,x,n)  for (ll k = x; k <= n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
#define vi vector <int>
#define mem(x, v) memset(x, v, sizeof(x));
#define int ll
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

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

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif

ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

bool isPrime(int n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int M = 3000+5;
const int N = 3e5+5;
const int maxn = 1e5+5;

void solve() {

    int n, k;
    cin >> n >> k;

    int a, b, c, d; cin >> a >> b >> c >> d;

    vll v;
    for(int i=1; i<=n; i++) {
        if(i != a && i!= b && i!= c && i!=d) v.pb(i);
    }

    if(k <= n || n == 4) {
        cout << -1 << endl;
        return;
    }

    cout << a << " ";
    cout << c << " ";
    for(auto x: v) cout << x << " ";
    cout << d << " ";
    cout << b << endl;

    cout << c << " ";
    cout << a << " ";
    for(auto x: v) cout << x << " ";
    cout << b << " ";
    cout << d << endl;

}

signed main() {
    fast_io;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int tc = 1;
    // cin >> tc;

    for(int i=1; i<=tc; i++) {
        // cout << "Case #" << i << ": " ;
        solve();
    }

    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}

// read the question correctly
// read code carefully
// corner cases // int vs ll // cin vs scanf // clear structures // maths
// check if max, min set to INT_MAX instead of INF
// check constraint


#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k, a, b, c, d;
	scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
	if(k <= n || n <= 4) {
		puts("-1");
		return 0;
	}
	for(int rep = 0; rep < 2; ++rep) {
		printf("%d %d ", a, c);
		for(int i = 1; i <= n; ++i)
			if(i != a && i != b && i != c && i != d)
				printf("%d ", i);
		printf("%d %d\n", d, b);
		swap(a, c);
		swap(b, d);
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <fstream>
#include <ctime>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    int c[4];

    for (int i = 0; i < 4; i++) {
        cin >> c[i];
    }

    if (n == 4 || k < n + 1) {
        cout << -1;
    } else {
        vector<int> g;

        for (int i = 1; i <= n; i++) {
            if (find(c, c + 4, i) == c + 4) {
                g.push_back(i);
            }
        }

        cout << c[0] << " " << c[2] << " ";

        for (int x : g) {
            cout << x << " ";
        }

        cout << c[3] << " " << c[1] << "\n";

        cout << c[2] << " " << c[0] << " ";

        for (int x : g) {
            cout << x << " ";
        }

        cout << c[1] << " " << c[3];
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define bp push_back
#define pause; system("pause");
#define mp make_pair
const int N=1e5+10;
const double eps=1e-9;
const int inf=1e9;
main(){

    int n,k,a,b,c,d;
    cin>>n>>k>>a>>b>>c>>d;
    if(n==4 || k<n+1)return cout<<-1,0;
    cout<<a<<" "<<c<<" ";
    for(int i=1;i<=n;i++)
        if(i!=a && i!=b && i!=c && i!=d)cout<<i<<" ";
    cout<<d<<" "<<b;
    cout<<endl;
    cout<<c<<" "<<a<<" ";
    for(int i=1;i<=n;i++)
        if(i!=a && i!=b && i!=c && i!=d)cout<<i<<" ";
    cout<<b<<" "<<d;
}


#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
#ifndef ONLINE_JUDGE
    freopen("../ip.txt", "r", stdin);
    freopen("../op.txt", "w", stdout);
#else
    AKASH_PATEL;
    SVNIT_SURAT;
#endif
    int t=1;
//    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int vis[n+1];
        mset(vis,0)
        vis[a]=1;
        vis[b]=1;
        vis[c]=1;
        vis[d]=1;
        vector <int> v;
        int x=-1;
        fpr(i,1,n+1)
        {
            if(!vis[i])
            {
                if(x==-1)
                {
                    x=i;
                    continue;
                }
                v.pb(i);
            }
        }
        if(n==4 || k<=n)
        {
            print("-1")
            return 0;
        }
        cout<<a<<" ";
        for(auto it:v)
        {
            cout<<it<<" ";
        }
        cout<<c<<" "<<x<<" "<<d<<" "<<b<<"\n";
        cout<<c<<" ";
        for(auto it:v)
        {
            cout<<it<<" ";
        }
        cout<<a<<" "<<x<<" "<<b<<" "<<d<<'\n';
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
#ifndef ONLINE_JUDGE
    freopen("../ip.txt", "r", stdin);
    freopen("../op.txt", "w", stdout);
#else
    AKASH_PATEL;
    SVNIT_SURAT;
#endif
    int t=1;
//    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        if(k==n-1)
        {
            print("-1")
            return 0;
        }
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int vis[n+1];
        mset(vis,0)
        vis[a]=1;
        vis[b]=1;
        vis[c]=1;
        vis[d]=1;
        vector <int> v;
        v.pb(a);
        v.pb(b);
        v.pb(c);
        v.pb(d);
        fpr(i,1,n+1)
        {
            if(!vis[i])
            {
                v.pb(i);
            }
        }
        cout<<a<<' ';
        fdr(i,v.sz-1,0)
        {
            cout<<v[i]<<" ";
        }
        nl
        fdr(i,2,-1)
        {
            cout<<v[i]<<" ";
        }
        fdr(i,n-1,2)
        {
            cout<<v[i]<<" ";
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#ifndef ONLINE_JUDGE
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#else
#define deb(x) ;
#define debug(x,y) ;
#define deb_arr(a,n) ;
#define deb_mat(dist,n,m) ;
#endif
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
#ifndef ONLINE_JUDGE
    freopen("../ip.txt", "r", stdin);
    freopen("../op.txt", "w", stdout);
#else
    AKASH_PATEL;
    SVNIT_SURAT;
#endif
    int t=1;
//    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int vis[n+1];
        mset(vis,0)
        vis[a]=1;
        vis[b]=1;
        vis[c]=1;
        vis[d]=1;
        vector <int> v;
        int x=-1;
        fpr(i,1,n+1)
        {
            if(!vis[i])
            {
                if(x==-1)
                {
                    x=i;
                    continue;
                }
                v.pb(i);
            }
        }
        if(n==4 || k<=n)
        {
            print("-1")
            return 0;
        }
        cout<<a<<" ";
        for(auto it:v)
        {
            cout<<it<<" ";
        }
        cout<<c<<" "<<x<<" "<<d<<" "<<b<<"\n";
        cout<<c<<" ";
        reverse(all(v));
        for(auto it:v)
        {
            cout<<it<<" ";
        }
        cout<<a<<" "<<x<<" "<<b<<" "<<d<<'\n';
    }
    return 0;
}