#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:TYPE();}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:TYPE();}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=100005;

int n,a[MAXN][3],b[MAXN],c[2],d[2];
int fen[MAXN];
void add(int x,int v){for(++x;x<=n;x+=(x&-x))fen[x]+=v;}
int query(int x){int s=0;for(++x;x;x-=(x&-x))s+=fen[x];return s;}

int main()
{
	readint(n);
	for(int i=0;i<3;++i)for(int j=0;j<n;++j)readint(a[j][i]),--a[j][i];
	for(int j=0;j<n;++j)
	{
		if(a[j][1]%3!=1)return 0*printf("No\n");
		b[j]=a[j][1]/3;
		if(a[j][0]/3!=b[j] || a[j][2]/3!=b[j])return 0*printf("No\n");
		c[j&1]^=(a[j][0]%3==2);
		if((b[j]&1)!=(j&1))return 0*printf("No\n");
	}
	for(int i=0;i<n;i+=2)d[1]^=(i/2-query(b[i]))&1,add(b[i],1);
	memset(fen,0,sizeof(fen));
	for(int i=1;i<n;i+=2)d[0]^=(i/2-query(b[i]))&1,add(b[i],1);
	if(c[0]!=d[0] || c[1]!=d[1])printf("No\n");
	else printf("Yes\n");
	return 0;
}