/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 300010;

ll n;
pii pos[maxn];
ll ar[2][maxn];
ll ver[2], hor[2];

struct Fenwick {
    ll fen[maxn];
    void update(ll i) {
        for (++i; i < maxn; i += i & -i) fen[i] ^= 1;
    }
    ll get(ll i) {
        ll s = 0;
        for (++i; i > 0; i ^= i & -i) s ^= fen[i];
        return s;
    }
    void clear() {
        memset(fen, 0, sizeof fen);
    }
} fen;

void halt() {
    cout << "No\n";
    exit(0);
}

ll calc_inv(ll *ar, ll n) {
    fen.clear();
    ll s = 0;
    forir (i, n) {
        s ^= fen.get(ar[i]);
        fen.update(ar[i]);
    }
    return s;
}

void MAIN() {

    cin >> n;
    fori (i, 3) {
        fori (j, n) {
            ll x; cin >> x; --x;
            pos[x] = {i, j};
            ar[j % 2][j / 2] = x;
        }
    }
    for (ll i = 1; i < n * 3; i += 3) {
        if (pos[i].F != 1) halt();
    }
    for (ll i = 0; i < n * 3; i += 3) {
        if (pos[i].S != pos[i + 2].S || pos[i].S != pos[i + 1].S) halt();
        if (pos[i].F == 2 && pos[i + 2].F == 0) {
            hor[i / 3 % 2] ^= 1;
        }
        if (pos[i].S % 2 != i / 3 % 2) halt();
    }

    fori (i, 2) {
        ver[i] = calc_inv(ar[i], (n + 1 - i) / 2);
    }

    fori (i, 2) if (ver[i] ^ hor[i ^ 1]) halt();

    cout << "Yes\n";

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
5
9 6 15 12 1
8 5 14 11 2
7 4 13 10 3
    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 5504