#include <bits/stdc++.h>
#define exit {cout << "No\n"; return 0;}

using namespace std;

const int Nmax = 1e5 + 5;
int i, j, n, a[Nmax], A[5][Nmax], b[Nmax];

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=3; ++i)
        for(j=1; j<=n; ++j)
            cin >> A[i][j];

    int ans0 = 0, ans1 = 0;
    for(i=1; i<=n; ++i)
    {
        if(A[2][i] % 3 != 2) exit;
        if(A[1][i] == A[2][i] - 1 && A[3][i] == A[2][i]+1) a[i] = A[2][i] / 3 + 1, b[i] = 0;
            else if(A[1][i] == A[2][i] + 1 && A[3][i] == A[2][i] - 1) a[i] = A[2][i] / 3 + 1, b[i] = 1;
                else exit;
        if(i&1) ans1 ^= b[i];
            else ans0 ^= b[i];
    }

    for(i=1; i<=n; ++i) if( (a[i]&1) != (i&1) ) exit;

    for(i=1; i<=n; ++i)
        while(a[i] != i)
        {
            swap(a[i], a[a[i]]);
            if(i&1) ans0 ^= 1;
                else ans1 ^= 1;
        }

    if(ans0 || ans1) exit;
    cout << "Yes\n";

    return 0;
}
