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

int n,a[N],b[N],c[2][N],p[N][3],t1[2],t2[2];
void add(int *c,int x){
	for (; x<=n; x+=x&-x) c[x]^=1;
}
int getsum(int *c,int x){
	int y=0; for (; x; x^=x&-x) y^=c[x]; return y;
}
void gg(){ puts("No"); exit(0); }
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=0; i<3; i++)
		for (j=1; j<=n; j++) scanf("%d",&p[j][i]);
	for (i=1; i<=n; i++){
		if (abs(p[i][0]-p[i][1])!=1) gg();
		if (abs(p[i][2]-p[i][1])!=1) gg();
		if (p[i][0]<p[i][2]){
			a[i]=p[i][2]/3; b[i]=0;
		} else{
			a[i]=p[i][0]/3; b[i]=1;
		}
		if ((a[i]^i)&1) gg();
	}
	if (n==3){
		if (a[1]==1 && !b[1] && !b[2] && !b[3]) puts("Yes"); else
		if (a[1]==3 && b[1] && b[2] && b[3]) puts("Yes"); else puts("No");
		return 0;
	}
	for (i=n; i; i--){
		j=i&1;
		t1[j]^=b[i]; t2[j]^=getsum(c[j],a[i]);
		add(c[j],a[i]);
	}
	puts(t1[0]==t2[1] && t1[1]==t2[0]?"Yes":"No");
	return 0;
}
