#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 100050
int n,a[N],b[N],mp[N][3],l[2];
void gun() {
	puts("No"); exit(0);
}
int main() {
	scanf("%d",&n);
	int i,x,y,z;
	for(x=0;x<3;x++) for(i=1;i<=n;i++) scanf("%d",&mp[i][x]);
	for(i=1;i<=n;i++) {
		x=mp[i][0], y=mp[i][1], z=mp[i][2];
		if(x+1==y&&y+1==z) {
			if(z%3) gun();	
			a[i]=z/3, b[i]=0;
		}else if(x-1==y&&y-1==z) {
			if(x%3) gun();
			a[i]=x/3, b[i]=1;
		}else gun();
		if((a[i]&1)!=(i&1)) gun();
		if(b[i]) l[i&1]^=1;
	}
	for(i=1;i<=n;i++) {
		while(a[i]!=i) {
			l[!(i&1)]^=1;
			swap(a[i],a[a[i]]);
		}
	}
	puts(l[0]||l[1]?"No":"Yes");
}

#include<bits/stdc++.h>
using namespace std;
void gofail(){
	cout<<"No\n";
	exit(0);
}
const int N=100100;
int a[N],b[N],c[N],sum[3*N],sum1,sum2,n;
void add(int x){for(;x;x-=x&-x)sum[x]^=1;}
int qry(int x){int ans=0;for(;x<=3*n;x+=x&-x)ans^=sum[x];return ans;}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)cin>>b[i];
	for(int i=1;i<=n;++i)cin>>c[i];
	for(int i=1;i<=n;++i){
		if(a[i]<b[i]){
			if(a[i]+1!=b[i])gofail();
			if(b[i]+1!=c[i])gofail();
			if(c[i]%3)gofail();
			a[i]=a[i]/3+1;b[i]=0;
		}else{
			if(a[i]-1!=b[i])gofail();
			if(b[i]-1!=c[i])gofail();
			if(a[i]%3)gofail();
			a[i]=a[i]/3;b[i]=1;
		}
		if((a[i]^i)&1)gofail();
		if(i&1)sum2^=b[i];
		else sum1^=b[i];
	}
	for(int i=1;i<=n;i+=2){
		sum1^=qry(a[i]);
		add(a[i]);
	}
	memset(sum,0,sizeof sum);
	for(int i=2;i<=n;i+=2){
		sum2^=qry(a[i]);
		add(a[i]);
	}
	if(sum1||sum2)gofail();
	cout<<"Yes\n";
	return 0;
}
