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

#define fi first
#define se second
typedef pair<int,int> PII;


int inv[2], flips[2], n, t[2][1<<17], p[1<<17], a[5][1<<17];

void update(int idx, int idy) { for (;idx;idx-=(idx&-idx)) t[idy][idx]++; }
int get(int idx, int idy) {
    int ret = 0;
    for (; idx <= n; idx += (idx & -idx)) ret += t[idy][idx];
    return ret;
}

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

int main() {
    cin >> n;
    for (int i = 1; i <= 3; i++) for (int j = 1; j <= n; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        if (abs(a[1][i] - a[2][i]) != 1 || abs(a[2][i] - a[3][i]) != 1) lose();
        if (a[2][i] % 3 != 2) lose();
        int j = (a[1][i] + 2) / 3;
        if ((i - j) % 2) lose();

        inv[i&1] = (inv[i&1] + (a[1][i] > a[3][i])) % 2;
        p[j] = i;
    }
    for (int i = 1; i <= n; i++) {
        int x = get(p[i],(i&1));
        flips[i&1] = (flips[i&1] + x) % 2;
        update(p[i],(i&1));
    }
    if (flips[0] != inv[1] || flips[1] != inv[0]) lose();
    cout << "Yes\n";
}
