// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
template < class T > ostream &operator<<(ostream &o, const stack<T> &a) { o << "{"; for(auto tmp = a; tmp.size(); tmp.pop()) o << (a.size() == tmp.size() ? "" : ", ") << tmp.top(); o << "}"; return o; }
template <class T, class Container, class Compare > ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> a) { os << "{ (top) "; while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; }
template <class T, class Container > ostream &operator<<(ostream &os, queue<T, Container> a) { os << "{ "; while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop(); os << " }"; return os; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
#define DEBUG_OUT cerr
#endif
#if !defined(DEBUG_LEFT)
#define DEBUG_LEFT "\e[1;36m"
#endif
#if !defined(DEBUG_RIGHT)
#define DEBUG_RIGHT ":\e[m"
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<DEBUG_LEFT<<__LINE__ << DEBUG_RIGHT << " " <<#__VA_ARGS__<<" = "<<__debug_tap<<endl;}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


int n;

// NOTE : there's get and sum method.
/// --- BIT Library {{{ ///

template < class T = ll >
struct BIT {
  int n, m;
  T identity;
  vector< T > data;
  BIT() : n(0) {}
  BIT(int n, T identity = T()) : n(n), identity(identity), data(n, identity) {
    m = 1;
    while(m < n) m <<= 1;
  }
  void add(int i, T x) {
    i++;
    while(i <= n) {
      data[i - 1] = data[i - 1] + x;
      i += i & -i;
    }
  }
  T sum(int i) {
    if(i < 0) return identity;
    if(i >= n) i = n - 1;
    i++;
    T s = identity;
    while(i > 0) {
      s = s + data[i - 1];
      i -= i & -i;
    }
    return s;
  }
  T get(int i) { return sum(i) - sum(i - 1); }
  T range(int a, int b) { return sum(b) - sum(a - 1); }
  int lower_bound(T w) {
    int i = 0;
    for(int k = m; k > 0; k >>= 1) {
      if(i + k <= n && data[i + k - 1] < w) w -= data[(i += k) - 1];
    }
    return i;
  }
};

/// }}}--- ///

// require BIT
// inversions {{{
#include<iterator>
template<class InputIter, class T = typename iterator_traits<InputIter>::value_type>
vector<int> inversions(InputIter first, InputIter last, const bool right = 0) {
  int n = distance(first, last);
  vector<int> ret(n);
  BIT<> bit(n);
  int i = 0;
  InputIter ite = first;
  vector<pair<T, int>> v(n);
  for(; i < n; ++ite, ++i) v[i] = make_pair(*ite, i);
  if(right) sort(v.begin(), v.end()); else sort(v.rbegin(), v.rend());
  for(int i = 0; i < n; i++) {
    ret[v[i].second] = right ? i - bit.sum(v[i].second) : bit.sum(v[i].second);
    bit.add(v[i].second, 1);
  }
  return ret;
}

template<class T>
vector<int> inversions(vector<T> v, bool right = 0) {
  return inversions(v.begin(), v.end(), right);
}
// }}}


int a[3][112345];

void IMP() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  int rev0 = 0, rev1 = 0, inv0 = 0, inv1 = 0;
  for(int i = 0; i < 3; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
  vector<int> v0, v1;
  for(int j = 0; j < n; j++) {
    // 1, 2, 3 or 3, 2, 1
    array<int, 3> ar{a[0][j], a[1][j], a[2][j]}, ok1{1, 2, 0}, ok2{0, 2, 1};
    for(auto &e : ar) e %= 3;
    if(ar != ok1 && ar != ok2) IMP();
    if(abs(a[0][j] - a[1][j]) != 1 || abs(a[1][j] - a[2][j]) != 1) IMP();
    if(a[1][j] % 6 != (j & 1 ? 5 : 2)) IMP();
    (j & 1 ? rev1 : rev0) ^= (a[0][j] + 1 == a[1][j]) ^ (a[1][j] % 12 <= 5) ^ (j % 4 >= 2);
    (j & 1 ? v1 : v0).emplace_back(a[0][j]);
  }

  auto f0 = inversions(v0);
  auto f1 = inversions(v1);
  for(auto e : f0) inv0 ^= e & 1;
  for(auto e : f1) inv1 ^= e & 1;

  if((rev0 ^ inv1) | (rev1 ^ inv0)) IMP();
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3196