#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
bool t[N],s[4];
int n,a[4][N],id[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int get(int a,int b,int c)
{
	if(a%3==0 && b==a-1 && c==b-1) return -a/3;
	if(c%3==0 && b==c-1 && a==b-1) return c/3;
	return 0;
}

void ins(int x)
{
	for(int i=x; i; i-=i&-i) t[i]^=1;
}

bool query(int x)
{
	bool rt=0;
	for(int i=x; i<=n; i+=i&-i) rt^=t[i];
	return rt;
}

int main()
{
	n=getint();
	rep(i,1,3) rep(j,1,n) a[i][j]=getint();
	rep(i,1,n)
	{
		int t=get(a[1][i],a[2][i],a[3][i]);
		if(!t || (t^i)&1) return puts("No"),0;
		id[i]=abs(t);
		if(t<0) s[i&1]^=1;
	}
	for(int i=1; i<=n; i+=2)
		s[2]^=query(id[i]),ins(id[i]);
	memset(t,0,sizeof(t));
	for(int i=2; i<=n; i+=2)
		s[3]^=query(id[i]),ins(id[i]);
	if(s[0]==s[2] && s[1]==s[3]) puts("Yes");
	else puts("No");
	return 0;
}