#include <cstdio>
#include <cstdlib>

using namespace std;

template <class Type>
class Bit {
    public:
    Bit(int n) : size(n + 1) {
        bit = (Type *)calloc(size, sizeof(Type));
    }
    
    ~Bit() {
        free(bit);
    }
    
    void add(int x, Type value) {
        for (x++; x < size; x += x & -x) bit[x] += value;
    }
    
    //[0,x]
    Type sum(int x) {
        Type value = 0;
        
        for (x++; x > 0; x -= x & -x) value += bit[x];
        
        return value;
    }
    
    //[x,y]
    Type get(int x, int y) {
        return sum(y) - sum(x - 1);
    }
    
    private:
    
    int size;
    Type *bit;
};

int a[3][100000];
int b[300000][2];
int c[100000];
int f[100000];

int main() {
    int n, c1 = 0, c2 = 0, i, j;
    long long sum1 = 0, sum2 = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < 3; i++) {
        for (j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
            
            a[i][j]--;
            
            b[a[i][j]][0] = i;
            b[a[i][j]][1] = j;
        }
    }
    
    for (i = 0; i < n * 3; i += 3) {
        int x = b[i][0];
        int y = b[i][1];
        int z = i / 3;
        
        if (z % 2 != y % 2 || x == 1 || b[i + 1][1] != y || b[i + 2][1] != y) {
            puts("No");
            
            return 0;
        }
        
        c[y] = z;
        
        if (x == 0) {
            if (b[i + 1][0] != 1 || b[i + 2][0] != 2) {
                puts("No");
                
                return 0;
            }
        } else {
            if (b[i + 1][0] != 1 || b[i + 2][0] != 0) {
                puts("No");
                
                return 0;
            }
            
            f[y] = 1;
        }
    }
    
    Bit <int> b1(n + 1);
    Bit <int> b2(n + 1);
    
    for (i = 0; i < n; i++) {
        if (i % 2 == 0) {
            sum1 += b1.get(c[i], n);
            b1.add(c[i], 1);
            c1 += f[i];
        } else {
            sum2 += b2.get(c[i], n);
            b2.add(c[i], 1);
            c2 += f[i];
        }
    }
    
    if (sum1 % 2 == c2 % 2 && sum2 % 2 == c1 % 2) {
        puts("Yes");
    } else {
        puts("No");
    }
    
    return 0;
}

// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

void nosol(){puts("No");exit(0);}
int n,a[3][100111],rev[2],ord[2][100111];
int bit[100111];
void add(int x){for(;x<100111;x+=x&-x)bit[x]^=1;}
int query(int x){int ret=0;for(;x;x-=x&-x)ret^=bit[x];return ret;}
int getinv(int a[],int n)
{
	memset(bit,0,sizeof(bit));
	int ret=0;
	for(int i=0;i<n;i++)
	{
		ret^=(i&1)^query(a[i]);
		add(a[i]+1);
	}
	return ret;
}
int main()
{
	get1(n);
	for(int i=0;i<3;i++)for(int j=0;j<n;j++){get1(a[i][j]);a[i][j]--;}
	for(int i=0;i<n;i++)
	{
		if(a[0][i]/3!=a[1][i]/3||a[0][i]/3!=a[2][i]/3)nosol();
		if(a[0][i]/3%2!=i%2)nosol();
		if(a[1][i]*2!=a[0][i]+a[2][i])nosol();
		rev[i&1]^=(a[0][i]>a[1][i]);
		ord[i&1][i>>1]=a[0][i]/3;
	}
	if(getinv(ord[0],n+1>>1)!=rev[1])nosol();
	if(getinv(ord[1],n>>1)!=rev[0])nosol();
	puts("Yes");
	return 0;
}