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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100100;

struct Fen
{
	int A[MAX];
	int n;

	void init(int n)
	{
		this->n = n;
	}

	void add(int x, int val)
	{
		for (; x < n; x = x | (x + 1))
		{
			A[x] += val;
		}
	}

	int get(int x)
	{
		int res = 0;
		for (; x >= 0; x = (x & (x + 1)) - 1)
		{
			res += A[x];
		}
		return res;
	}

	int get(int l, int r)
	{
		int res = get(r);
		if (l) res -= get(l-1);
		return res;
	}
} F[2], G;

int A[MAX];
int B[MAX];

void move(vector<PII>& a, int x)
{
	swap(a[x-1], a[x+1]);
	a[x-1].second ^= 1;
	a[x].second ^= 1;
	a[x+1].second ^= 1;
}

set<vector<PII> > S;

void go(vector<PII> a)
{
	if (S.count(a)) return;
	/*FOR (i, 0, SZ(a))
	{
		cout<<a[i].first<<' '<<a[i].second<<", ";
	}
	cout<<endl;*/
	S.insert(a);
	FOR (i, 1, SZ(a) - 1)
	{
		move(a, i);
		go(a);
		move(a, i);
	}
//	cout<<"out"<<endl;
}

int WH[MAX];

int M[MAX][3];
int R[MAX];

void NO()
{
	cout<<"No"<<endl;
	exit(0);
}

int D[MAX];

int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	F[0].init(n);
	F[1].init(n);
	G.init(n);

	FOR (it, 0, 3)
	{
		FOR (i, 0, n)
		{
			int x;
			scanf("%d", &x);
			x--;

			M[i][it] = x;

			if (it == 0)
			{
				int y = x % 3;
				x /= 3;

				A[i] = x;
				B[x] = (y != 0);

				WH[x] = i;

				if (x % 2 != i % 2) NO();
			}
		}
	}

/*	FOR (i, 0, n)
	{
		cout<<B[i]<<' ';
	}
	cout<<endl;*/

	FOR (i, 0, n)
	{
		if (M[i][0] / 3 != M[i][1] / 3) NO();
		if (M[i][0] / 3 != M[i][2] / 3) NO();

		if (M[i][0] < M[i][1] && M[i][1] < M[i][2]) continue;
		if (M[i][0] > M[i][1] && M[i][1] > M[i][2]) continue;
		NO();
	}

	LL S[2] = {0, 0};

	RFOR (i, n, 0)
	{
		int pos = WH[i];
		D[i] = F[i&1].get(pos);
		S[i&1] += D[i];
	//	cout<<i<<' '<<D[i]<<endl;
		F[i&1].add(pos, 1);
	}

	FOR (i, 0, n)
	{
		S[1 ^ (i&1)] += B[i];
	}

//	cout<<S[0]<<' '<<S[1]<<endl;

	if (S[0] % 2 == 0 && S[1] % 2 == 0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;

	FOR (i, 0, n)
	{
		//cout<<i<<' '<<WH[i]<<endl;;
		int x = i;

		int pos = WH[i];

		int dst = 0;

		dst = D[i];
		G.add(pos, 1);
			/*FOR (i, 0, n)
			{
				if (WH[i] <= pos) B[i]++, cout<<"* "<<i<<endl;
			}*/

	/*	FOR (i, 0, n)
		{
			cout<<B[i]<<' ';
		}
		cout<<endl;

		FOR (i, 0, n)
		{
			cout<<G.get(i)<<' ';
		}
		cout<<endl;*/

		//cout<<x<<": "<<G.get(pos)<<' '<<B[x]<<' '<<dst<<endl;

		R[x] = (G.get(pos + 1, n-1) + B[x]  + dst) % 2;
	}
	cout<<endl;

	FOR (i, 0, n)
	{
		cout<<R[i]<<' ';
	}
	cout<<endl;

	int p = 0;
	if (n % 2 == 0) p = 1;
	FOR (i, 0, n - 2)
	{
		if (R[i])
		{
			R[i] ^= 1;
			R[n - p - 1] ^= 1;
		}
		p ^= 1;
	}

	bool ok = true;
	FOR (i, 0, n)
	{
	//	cout<<R[i]<<' ';
		if (R[i]) ok = false;
	}
	//cout<<endl;
	if (ok) cout<<"Yes"<<endl;
	else NO();

	/*int n;
	scanf("%d", &n);

	vector<PII> a;

	FOR (i, 0, n)
	{
		a.PB(MP(i, 0));
	}

	go(a);

	ITER(it, S)
	{
		vector<PII> a = *it;
		bool ok = true;
		FOR (i, 0, SZ(a))
		{
			if (a[i].first != i) ok = false;
		}

		if (ok)
		{
			FOR (i, 0, SZ(a))
			{
				cout<<a[i].second<<' ';
			}
			cout<<endl;
		}
	}
	cout<<endl;
	return 0;*/
/*
	int n;
	scanf("%d", &n);

	FOR (i, 0, n)
	{
		int x;
		scanf("%d", &x);
		x--;
		int y = x % 3;
		x /= 3;

		A[i] = x;
		B[i] = (y == 0);
	}

	while(true)
	{
		FOR (i, 0, n)
		{
			cout<<i<<' ';
		}
		cout<<endl;
		FOR (i, 0, n)
		{
			cout<<" |"[B[i]]<<' ';
		}
		cout<<endl;
		FOR (i, 0, n)
		{
			cout<<A[i]<<' ';
		}
		cout<<endl;
		FOR (i, 0, n)
		{
			cout<<"| "[B[i]]<<' ';
		}
		cout<<endl;
		cout<<endl;

		int x;
		cin>>x;

		while(x <= 0 || x >= n-1)
		{
			cin>>x;
		}

		swap(A[x-1], A[x+1]);
		swap(B[x-1], B[x+1]);

		B[x-1] ^= 1;
		B[x] ^= 1;
		B[x+1] ^= 1;
	}*/

}


Measured memory_bytes: 4096