#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
class fenwick_tree {
public:
  using value_type = T;

private:
  int size;
  std::vector<value_type> node;

public:
  fenwick_tree() = default;
  fenwick_tree(int size_) { init(size_); }

  void init(int size_) {
    size = size_;
    node.assign(size_ + 1, 0);
  }

  void modify(int i, const value_type& x) {
    ++i;
    while (i <= size) {
      node[i] += x;
      i += i & -i;
    }
  }

  value_type get(int i) const {
    ++i;
    value_type res = 0;
    while (i > 0) {
      res += node[i];
      i -= i & -i;
    }
    return res;
  }
  value_type fold(int l, int r) const {
    return get(r - 1) - get(l - 1);
  }

};

int main() {
  int N;
  std::cin >> N;
  std::vector<std::vector<int>> A(3, std::vector<int>(N));
  for (auto &vec: A) {
    for (int &x: vec) {
      std::cin >> x;
      --x;
    }
  }
  auto answer = [](bool condition) {
    std::puts(condition ? "Yes" : "No");
    std::exit(0);
  };
  std::vector<std::vector<int>> arr(2);
  std::vector<std::vector<bool>> flp(2);
  for (int j: range(0, N)) {
    if (A[1][j] % 3 != 1) {
      answer(false);
    }
    bool flipped = (A[0][j] > A[2][j]);
    A[0][j] /= 3;
    A[1][j] /= 3;
    A[2][j] /= 3;
    if (!(A[0][j] == A[1][j] && A[1][j] == A[2][j])) {
      answer(false);
    }
    arr[j % 2].push_back(A[1][j]);
    flp[j % 2].push_back(flipped);
  }
  for (int i: range(0, 2)) {
    for (int j: range(0, arr[i].size())) {
      if (arr[i][j] % 2 != i) {
        answer(false);
      }
      arr[i][j] /= 2;
    }
  }
  auto swaps = [&](const std::vector<int> &vec) {
    fenwick_tree<int> fen(vec.size());
    long long res = 0;
    for (int x: vec) {
      res += fen.fold(x, vec.size());
      fen.modify(x, 1);
    }
    return res;
  };
  for (int i: range(0, 2)) {
    long long s = swaps(arr[i ^ 1]);
    int t = std::count(flp[i].cbegin(), flp[i].cend(), true);
    if (s % 2 != t % 2) {
      answer(false);
    }
  }
  answer(true);
  return 0;
}


Measured memory_bytes: 2296