#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

string yes = "Yes";
string no = "No";

template<typename T>struct fenwick_tree{
	vector<T> x;
	fenwick_tree(int n){
		int m=1;
		while(m<n)m*=2;
		x=vector<T> (m);
	}
	// [i,j)区間
	void range(int i,int j, T d){
		if(i!=0){
			range(0,j,d);
			range(0,i,-d);
			return;
		}
		j-=1;
		for( ;j>=0;j=(j&(j+1))-1){
			x[j]+=d;
		}
	}
	T point(int k){
		T ret=0;
		for(;k<x.size(); k|=k+1) ret+=x[k];
		return ret;
	}
};

const int M = 100100;
ll tenti(vl a){
	fenwick_tree<ll> fen(M);
	ll ret = 0;
	rep(i,a.size()){
		ll v = a[i];
		ret += fen.point(v);
		fen.range(0,v,1);
	}
	return ret;

}


void _main(istream &inp){
	vl a[3];
	int n;
	inp >> n;
	rep(x,3){
		a[x]  = vl(n);
		rep(y,n){
			int t;
			inp >> t;
			t--;
			a[x][y]=t;
		}
	}
	vl seq(n);
	vl parity(n);
	rep(y,n){
		int m = a[0][y]/3;
		seq[y]=m;
		if(a[0][y]==3*m && a[1][y]==3*m+1 && a[2][y]==3*m+2){
			parity[y]=0;
		}
		else if(a[0][y]==3*m+2 && a[1][y]==3*m+1 && a[2][y]==3*m){
			parity[y]=1;
		}
		else{
			cout << no << endl;
			return;
		}
		if(m%2!=y%2){
			cout << no << endl;
			return;
		}
	}
	vl os, es;
	int on = 0 , en = 0;
	rep(i,n){
		if(i%2==1){
			on += parity[i];
			os.push_back(seq[i]);
		}
		else{
			en += parity[i];
			es.push_back(seq[i]);
		}
	}
	//deb(en);deb(on);deb(es);deb(os);deb(tenti(es));deb(tenti(os));debl;
	if( (tenti(os)+en)%2==1 || (tenti(es)+on)%2==1){
		cout << no << endl;
	}
	else{
		cout << yes << endl;
	}

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 6768