#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;
}