#include<bits/stdc++.h>
#define lowbit(x) ((x)&-(x))

using namespace std;

inline void Assert(bool f){if(!f)puts("No"),exit(0);}

const int N=100005;
int n,a[N],b[N],v[N],perm[N],m,sum[N],pos[N];
bool rev[N],inv[2];

inline int ABS(int x){return x<0?-x:x;}
inline void inc(int x,int u){
	while(x<=n) sum[x]+=u,x+=lowbit(x);
}
inline int calc(int x){
	int r=x; while(x) r-=sum[x],x-=lowbit(x); return r;
}
bool chk(){
	memset (sum+1, 0, n<<2);
	for (int i=1; i<=m; i++) pos[perm[i]]=i;
	long long ti = 0;
	for (int i=1; i<=m; i++) ti += calc(pos[i]) - 1, inc (pos[i], 1);
	return ti & 1;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		Assert(a[i]%3==2);
		if(v[i]==a[i]+1)rev[i]=true;
		else Assert(v[i]==a[i]-1);
		b[i]=a[i]/3+1;
		Assert((b[i]&1)==(i&1));
		inv[i&1]^=rev[i];
	}
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		Assert(x+v[i]==2*a[i]);
	}
	m=0;for(int i=1;i<=n;i+=2)perm[++m]=b[i]/2+1;
	Assert((chk()^inv[0])%2==0);
	m=0;for(int i=2;i<=n;i+=2)perm[++m]=b[i]/2;
	Assert((chk()^inv[1])%2==0);
	puts("Yes");
	return 0;
}