// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<unordered_set>

#include<complex>

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 int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 2 * 1000 * 100 + 47;



struct Fenvic

{

	int T[MAX];

	int n;

	void init(int n1)

	{

		n = n1;

		FOR(i, 0, n) T[i] = 0;

	}



	void add(int i, int delta)

	{

		for (; i < n; i = i | (i + 1))

		{

			T[i] += delta;

		}

	}



	int get(int i)

	{

		int res = 0;

		for (; i >= 0; i = (i & (i + 1)) - 1)

		{

			res += T[i];

		}



		return res;

	}



	int get(int l, int r)

	{

		int res = get(r);

		if (l) res -= get(l - 1);

		return res;

	}

} F;



int A[MAX];

int B[MAX];

int C[3][MAX];

int U[MAX];



void no()

{

	cout << "No" << endl;

	exit(0);

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(false); cin.tie(0);

	int n;

	cin >> n;

	FOR(i, 0, 3)

	{

		FOR(j, 0, n)

		{

			cin >> C[i][j];

			C[i][j]--;

		}

	}



	FOR(j, 0, n)

	{

		if (C[0][j] / 3 != C[1][j] / 3 || C[0][j] / 3 != C[2][j] / 3) no();



		A[j] = C[0][j] / 3;

		if (C[0][j] < C[1][j] && C[1][j] < C[2][j])

		{

			B[j] = 0;

			continue;

		}



		if (C[0][j] > C[1][j] && C[1][j] > C[2][j])

		{

			B[j] = 1;

			continue;

		}



		no();

	}



	FOR(i, 0, n)

	{

		if (i % 2 != A[i] % 2) no();

	}



	int odd = (n - n / 2) & 1;

	int even = (n / 2) & 1;

	FOR(i, 0, n)

	{

		if (!U[i])

		{

			int x = i;

			while (!U[x])

			{

				U[x] = 1;

				x = A[x];

			}



			if (i & 1)

			{

				even ^= 1;

				continue;

			}

			

			odd ^= 1;

		}

	}



	//F.init(n);

	//int odd = 0;

	//for (int i = 0; i < n; i += 2)

	//{

	//	odd ^= F.get(A[i] + 1, n - 1) % 2;

	//	F.add(A[i], 1);

	//}



	//F.init(n);

	//int even = 0;

	//for (int i = 1; i < n; i += 2)

	//{

	//	even ^= F.get(A[i] + 1, n - 1) % 2;

	//	F.add(A[i], 1);

	//}



	FOR(i, 0, n)

	{

		if (i % 2 == 0 && B[i] == 1) even ^= 1;

		if (i % 2 == 1 && B[i] == 1) odd ^= 1;

	}



	if (odd == 0 && even == 0)

	{

		cout << "Yes" << endl;

		return 0;

	}



	cout << "No" << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.306470334708255x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 100000

using namespace std;

int rec[MAXN+5][4];

int seq[2][MAXN+5],len[2],tmp[MAXN+5];

int need[2];

int MergeSort(int l,int r,int id)

{

	if(l>=r)

		return 0;

	int ret=0;

	int mid=(l+r)/2;

	ret+=(MergeSort(l,mid,id)%2+MergeSort(mid+1,r,id)%2)%2;

	int i=l,j=mid+1,k=l;

	for(k=l;k<=r;k++)

	{

		if(j>r||(i<=mid&&seq[id][i]<seq[id][j]))

			tmp[k]=seq[id][i++];

		else

		{

			ret+=mid-i+1;

			ret%=2;

			tmp[k]=seq[id][j++];

		}

	}

	for(int i=l;i<=r;i++)

		seq[id][i]=tmp[i];

	return ret;

}

int main()

{

	int N;

	scanf("%d",&N);

	for(int i=1;i<=3;i++)

		for(int j=1;j<=N;j++)

			scanf("%d",&rec[j][i]);

	bool legal=true;

	for(int j=1;j<=N;j++)

	{

		if(rec[j][1]+1==rec[j][2]&&rec[j][2]+1==rec[j][3])

		{

			if((rec[j][1]%6!=1&&j%2==1)||(rec[j][1]%6!=4&&j%2==0))

			{

				legal=false;

				break;

			}

			seq[j%2][++len[j%2]]=rec[j][1]/6+1;

		}

		else if(rec[j][1]-1==rec[j][2]&&rec[j][2]-1==rec[j][3])

		{

			if((rec[j][3]%6!=1&&j%2==1)||(rec[j][3]%6!=4&&j%2==0))

			{

				legal=false;

				break;

			}

			need[j%2]++;

			seq[j%2][++len[j%2]]=rec[j][3]/6+1;

		}

		else

		{

			legal=false;

			break;

		}

	}

	int cnt0=MergeSort(1,len[1],1);

	int cnt1=MergeSort(1,len[0],0);

	need[0]%=2,need[1]%=2;

	if(cnt0!=need[0]||cnt1!=need[1])

		legal=false;

	if(legal==false)

		printf("No\n");

	else

		printf("Yes\n");

	return 0;

}