#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100005
using namespace std;
int n,w[4][N],a[N],sum[2][N],inv[2],flip[2];
void add(int *sum,int k,int val){
	val&=1;
	for(k;k<=n;k+=k&-k) sum[k]^=val;
}
int find(int *sum,int k){
	int ans=0;
	for(k;k;k-=k&-k) ans^=sum[k];
	return ans;
}
int zh(int a){return a<0?-a:a;}
bool pan(){
	for(int i=1;i<=n;i++){
		if(w[1][i]<w[3][i]){
			if(w[2][i]!=w[1][i]+1||w[2][i]!=w[3][i]-1) return 0;
			if(w[3][i]%3) return 0;
			a[i]=w[3][i]/3;
		}else{
			if(w[2][i]!=w[3][i]+1||w[2][i]!=w[1][i]-1) return 0;
			if(w[1][i]%3) return 0;
			a[i]=-w[1][i]/3;
		}
	}
	for(int i=1;i<=n;i++){
		if(i%2!=(a[i]%2+2)%2) return 0; 
	}
	for(int i=1;i<=n;i++){
		inv[i&1]^=(a[i]<0);
		flip[i&1]^=find(sum[i&1],n)^find(sum[i&1],zh(a[i])-1);
		add(sum[i&1],zh(a[i]),1);
	}
	if(inv[0]==flip[1]&&inv[1]==flip[0]) return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int p=1;p<=3;p++)
		for(int i=1;i<=n;i++) scanf("%d",&w[p][i]);
	if(pan()) puts("Yes");
	else puts("No");
	return 0;
}