#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

template<typename T> class BIT {
private:
	int n;
	vector<T> bit;
public:
	// 0_indexed で i 番目の要素に x を加える
	void add(int i, T x){
		i++;
		while(i < n){
			bit[i] += x, i += i & -i;
		}
	}
	// 0_indexed で [0,i] の要素の和(両閉区間！！)
	T sum(int i){
		i++;
		T s = 0;
		while(i > 0){
			s += bit[i], i -= i & -i;
		}
		return s;
	}
	BIT(){}
	//初期値がすべて0の場合
	BIT(int sz) : n(sz+1), bit(n, 0){}
	BIT(vector<T>& v) : n((int)v.size()+1), bit(n, 0){
		for(int i = 0; i < n-1; i++){
			add(i,v[i]);
		}
	}
	void print(){
		for(int i = 0; i < n-1; i++){
			cout<<sum(i)-sum(i-1)<< " ";
		}
		cout<<endl;
	}
	//-1スタート
	void print_sum(){
		for(int i = 0; i < n; i++){
			cout<<sum(i-1)<<" ";
		}
		cout<<endl;
	}
};


int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(3,vector<int>(n));
    rep(i,3){
        rep(j,n){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    vector<int>p,s(n),q,invp(n),invq(n);
    vector<int>aa;
    for(int j=0;j<n;j++){
        int mi = inf;
        rep(i,3){
            mi = min(mi,a[i][j]);
        }
        if(mi%3!=0){
            cout << "No" << endl;
            return 0;
        }
        int k = mi/3;
        aa.push_back(k);
        if(j%2==0){
            if(k%2==0){
                p.push_back(k/2);
                invp[k/2] = j/2;
                if(a[0][j]==mi){
                    if(a[1][j]==mi+1&&a[2][j]==mi+2){
                        s[k] = 0;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }else if(a[1][j]==mi){
                    cout << "No" << endl;
                    return 0;
                }else{
                    if(a[1][j]==mi+1&&a[0][j]==mi+2){
                        s[k] = 1;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(k%2==1){
                q.push_back(k/2);
                invq[k/2] = j/2;
                if(a[0][j]==mi){
                    if(a[1][j]==mi+1&&a[2][j]==mi+2){
                        s[k] = 0;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }else if(a[1][j]==mi){
                    cout << "No" << endl;
                    return 0;
                }else{
                    if(a[1][j]==mi+1&&a[0][j]==mi+2){
                        s[k] = 1;
                    }else{
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    vector<int> ppp(n,1);
    BIT<int> bit(ppp),bit2(ppp);
    vector<int> c(n),d(n);
    vector<int> x(n);
    rep(i,p.size()){
        int k = invp[i];
        int ss = bit.sum(k);
        int cnt = (n-k- (bit.sum(n-1)-bit.sum(k-1)));
        bit.add(k,-1);
        c[i]++;
        c[i+ss-1]--;
        x[2*i] += ss-1 + cnt;
        x[2*i] %= 2;
        
    }
    rep(i,q.size()){
        int k = invq[i];
        int ss = bit2.sum(k);
        int cnt = (n-k- (bit2.sum(n-1)-bit2.sum(k-1)));
        
        bit2.add(k,-1);
        d[i]++;
        d[i+ss-1]--;
        
        x[2*i+1] += ss-1 + cnt;
        x[2*i+1] %= 2;
        
    }
    rep(i,n-1){
        c[i+1] += c[i];
    }
    rep(i,n-1){
        d[i+1] += d[i];
    }
    rep(i,n)c[i] %= 2;
    rep(i,n)d[i] %= 2;
    rep(i,n){
        if(c[i]){
            // cerr << i << " " << aa[2*i+1] << endl;
            x[aa[2*i+1]]++;
        }
    }
    rep(i,n){
        if(d[i]){
            x[2*i+2]++;
        }
    }
    rep(i,n){
        x[i]%=2;
    }
    rep(i,n){
        x[i] ^= s[i];
    }
    for(int i=0;i<n;i++){
        if(x[i]!=0){
            if(i<n-2){
                x[i]^=1;
                x[i+2]^=1;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6016