#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=200005;
int num[2][N],a[4][N],n,cnt[2];
void insert(int flag,int x){
	for (;x;x-=x&-x)num[flag][x]++;
}
int find(int flag,int x){
	int ans=0;
	for (;x<N;x+=x&-x)ans+=num[flag][x];
	return ans;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=3;i++)
		for (int j=1;j<=n;j++)scanf("%lld",&a[i][j]),a[i][j]--;
	for (int i=1;i<=n;i++){
		if (a[2][i]%3!=1){
			puts("No");
			return 0;
		}
		if (a[1][i]/3!=a[2][i]/3||a[2][i]/3!=a[3][i]/3){
			puts("No");
			return 0;
		}
		int t=i&1;
		if (t^(!((a[2][i]/3)&1))){
			puts("No");
			return 0;
		}
		if (a[1][i]%3!=0)cnt[t^1]++;
		cnt[t]+=find(t,a[1][i]/3+1);
		insert(t,a[1][i]/3+1);
	}
	if (cnt[1]%2||cnt[0]%2){
		puts("No");
		return 0;
	}
	puts("Yes");
}