#include <iostream>
#include <vector>
#include <functional>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

template <class T>
struct SegmentTree {
    using Merger = std::function<T(T, T)>;

    int length;
    std::vector<T> dat;
    T unit;
    Merger merge;

    explicit SegmentTree(int n, const T& unit, const Merger& merge)
        : length(1), unit(unit), merge(merge) {
        while (length < n) length <<= 1;
        dat.assign(length * 2, unit);
    }

    template <class Container>
    explicit SegmentTree(const Container& elems, const T& unit, const Merger& merge)
        : length(1), unit(unit), merge(merge) {
        int n = elems.size();
        while (length < n) length <<= 1;
        dat.assign(length * 2, unit);

        std::copy(elems.begin(), elems.end(), dat.begin() + length);

        for (int nidx = length - 1; nidx >= 1; --nidx) {
            T vl = dat[nidx * 2 + 0];
            T vr = dat[nidx * 2 + 1];
            dat[nidx] = merge(vl, vr);
        }
    }

    T get(int idx) { return dat[idx + length]; }
    T whole() { return dat[1]; }

    T query(int ql, int qr) {
        ql = std::max(ql, 0);
        qr = std::min(qr, length);
        ql += length, qr += length;

        T lacc = unit, racc = unit;
        while (ql < qr) {
            if (ql & 1) {
                lacc = merge(lacc, dat[ql]);
                ++ql;
            }
            if (qr & 1) {
                --qr;
                racc = merge(dat[qr], racc);
            }
            ql >>= 1, qr >>= 1;
        }

        return merge(lacc, racc);
    }

    void update(int nidx, const T& elem) {
        nidx += length;
        dat[nidx] = elem;

        while (nidx > 0) {
            nidx >>= 1;
            T vl = dat[nidx * 2 + 0];
            T vr = dat[nidx * 2 + 1];
            dat[nidx] = merge(vl, vr);
        }
    }
};

void solve() {
    int n;
    std::cin >> n;

    auto xss = vec(n, vec(3, 0));
    for (int j = 0; j < 3; ++j) {
        for (int i = 0; i < n; ++i) {
            std::cin >> xss[i][j];
            --xss[i][j];
        }
    }

    std::vector<int> ls(n, -1), dir(n);
    for (int i = 0; i < n; ++i) {
        if (xss[i][0] + 1 == xss[i][1] &&
            xss[i][1] + 1 == xss[i][2] &&
            xss[i][0] % 3 == 0) {
            ls[i] = xss[i][0] / 3;
            dir[i] = 0;

        } else if (xss[i][0] - 1 == xss[i][1] &&
                   xss[i][1] - 1 == xss[i][2] &&
                   xss[i][0] % 3 == 2) {
            ls[i] = xss[i][0] / 3;
            dir[i] = 1;
        }

        if (ls[i] % 2 != i % 2) ls[i] = -1;

        if (ls[i] == -1) {
            std::cout << "No" << std::endl;
            return;
        }
    }

    std::vector<int> revs(2, 0), dsum(2, 0);
    for (int p = 0; p < 2; ++p) {
        SegmentTree<int> seg(n, 0,
                             [](auto a, auto b) {
                                 return a + b;
                             });

        for (int i = p; i < n; i += 2) {
            revs[p] += seg.query(ls[i], n) % 2;
            seg.update(ls[i], 1);
            dsum[p] += dir[i];
        }
        revs[p] %= 2;
        dsum[p] %= 2;
    }

    std::cout << (revs[0] == dsum[1] && revs[1] == dsum[0] ? "Yes" : "No")
              << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 7680