#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#define RG register
using namespace std;
const int N=1e5+10;
int n,a[4][N],num[2],to[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline void swp(I&a,I&b){a^=b; b^=a; a^=b;}
template<typename I>inline I abss(const I a){return a>0 ? a : -a;}
int main()
{
//	freopen("Rotate 3x3.in","r",stdin);
	read(n);
	for(RG int i=1;i<=n;i++) 
	{
		read(a[1][i]);
		if(a[1][i]%3==2) return printf("No\n"), 0;
	}
	for(RG int i=1;i<=n;i++)
	{
		read(a[2][i]); to[i]=(a[2][i]-1)/3+1;
		if(a[2][i]%3!=2 || (a[2][i]-1)/3!=(a[1][i]-1)/3 || abss(to[i]-i)&1) return printf("No\n"), 0;
		num[i&1]^=(a[1][i]>a[2][i]);
	}
	for(RG int i=1;i<=n;i++)
	{
		read(a[3][i]);
		if((a[3][i]-1)/3!=(a[2][i]-1)/3) return printf("No\n"), 0;
	}
	for(RG int i=1;i<=n;i++)
	 while(to[i]!=i) num[i&1^1]^=1, swp(to[i],to[to[i]]);
	printf("%s\n",num[0]|num[1] ? "No" : "Yes");
	return 0;
}