#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef unsigned long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll bit[1 << 17][2]; int n;
void add(int id,int a, ll w) {
	for (int i = a; i <= n + 1; i += i & -i)bit[i][id] += w;
}
ll sum(int id,int a) {
	ll ret = 0;
	for (int i = a; i > 0; i -= i & -i)ret += bit[i][id];
	return ret;
}
int a[1 << 17][3];
P b[1 << 17];
int main() {
	cin >> n;
	rep(i, 3) {
		rep(j, n) {
			cin >> a[j][i]; a[j][i]--;
		}
	}
	bool f = true;
	rep(i, n) {
		int key = a[i][0]/3;
		rep1(j, 2) {
			if (key != a[i][j] / 3)f = false;
		}
		if (a[i][1] == a[i][0] + 1 && a[i][2] == a[i][0] + 2) {
			b[key] = { i+1,0 };
		}
		else if (a[i][1] == a[i][0] - 1 && a[i][2] == a[i][0] - 2) {
			b[key] = { i+1,1 };
		}
		else f = false;
		if (i % 2 != key % 2)f = false;
		//cout << key << endl;
	}
	if (!f) {
		cout << "No" << endl;
	}
	else {
		ll cnt[2] = {};
		rep(i, n) {
			int k = i % 2;
			cnt[k ^ 1] += b[i].second;
			cnt[k] += (b[i].first-1)/2 - sum(k,b[i].first);
			add(k,b[i].first,1);
			//cout << cnt << endl;
		}
		//cout << cnt[0] << " " << cnt[1] << endl;
		if (cnt[0]% 2==0&&cnt[1]%2==0)cout << "Yes" << endl;
		else cout << "No" << endl;
		//cout << cnt << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

double ev[305][305][305], p[305][305][305];

int main() 
{
    int n;
    cin>>n;

    vector<int> cnt(4,0);

    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;

        cnt[x]++;
    }   

    p[cnt[1]][cnt[2]][cnt[3]] = 1;

    for(int c=n; c >= 0; c--)
    {
        for(int b=n; b >= 0; b--)
        {
            for(int a=n; a >= 0; a--)
            {
                if(a==0 && b==0 && c==0)
                    continue;

                if(a+b+c > n)
                    continue;

                double p_waste = (double)(n - (a+b+c))/n;
                double ev_waste = (double)p_waste/(1 - p_waste);

                //debug() << imie(a) imie(b) imie(c) imie(ev_waste);

                ev[a][b][c] += ev_waste*p[a][b][c];

                if(a != 0)
                {
                    double p_go = (double)a/(a+b+c);
                    p[a-1][b][c] += p[a][b][c]*p_go;
                    ev[a-1][b][c] += ev[a][b][c]*p_go;
                }

                if(b != 0)
                {
                    double p_go = (double)b/(a+b+c);
                    p[a+1][b-1][c] += p[a][b][c]*p_go;
                    ev[a+1][b-1][c] += ev[a][b][c]*p_go;
                }

                if(c != 0)
                {
                    double p_go = (double)c/(a+b+c);
                    p[a][b+1][c-1] += p[a][b][c]*p_go;
                    ev[a][b+1][c-1] += ev[a][b][c]*p_go;
                }
            }
        }
    }

    cout<<fixed<<setprecision(10)<<ev[0][0][0] + cnt[1] + 2*cnt[2] + 3*cnt[3]<<endl;
}
