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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;

struct FenwickTree{
    vi bit;
    int n;

    FenwickTree(int n = 0){
        this->n = n + 1;
        bit.assign(this->n + 1, 0);
    }

    FenwickTree(vector<int> a) : FenwickTree(a.size()){
        this->n = a.size() + 1;
        bit.assign(n + 1, 0);
        For(i, 0, a.size()){
            add(i, a[i]);
        }
    }

    int sum(int idx){
        int ans = 0;
        for (; idx > 0; idx -= idx & -idx){
            ans += bit[idx];
        }
        return ans;
    }

    int sum(int l, int r){
        return sum(r) - sum(l - 1);
    }

    void add(int idx, int delta){
        for (; idx <= n; idx += idx & -idx){
            bit[idx] += delta;
        }
    }
};

int n;
int a[4][N];
bool ck[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ForE(i, 1, 3){
        ForE(j, 1, n){
            cin >> a[i][j];
        }
    }
    ForE(j, 1, n){
        int sum = a[1][j] + a[2][j] + a[3][j];
        int mn = min(a[1][j], min(a[2][j], a[3][j]));
        int mx = max(a[1][j], max(a[2][j], a[3][j]));
        // cout << "J " << j << endl;
        // cout << ck[mn] << endl;
        // cout << sum << ' ' << mn << ' ' << mx << ' ' << sum - mn - mx << endl;
        // cout << a[2][j] << endl;
        if (!ck[mn] && sum * 2 == mn * 3 + mx * 3 && mx % 3 == 0 && a[2][j] == sum - mn - mx){
            ck[mn] = 1;
            if (j % 2 != mn % 2) Ptest("No");
        }
        else{
            Ptest("No");
        }
    }
    FenwickTree bit1(n), bit2(n);
    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
    ForE(j, 1, n){
        int mn = min(a[1][j], min(a[2][j], a[3][j]));
        if (j % 2 == 1){
            x1 += bit1.sum((mn / 6 + 1) + 1, n);
            x1 &= 1;
            bit1.add((mn / 6 + 1), 1);
            if (mn == a[3][j]){
                y1 ^= 1;
            }
        }
        else{
            x2 += bit2.sum((mn / 6 + 1) + 1, n);
            x2 &= 1;
            bit2.add((mn / 6 + 1), 1);
            if (mn == a[3][j]){
                y2 ^= 1;
            }
        }
    }
    // cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << endl;
    if ((x1 ^ y2) || (x2 ^ y1)) Ptest("No");
    cout << "Yes";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 7364