/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include<vector>

class BitSum {
    vector<long long> bit;
    int MAXN;

    // return bit[1] + ... + bit[i]
public: long long sum(int i) {
      long long s = 0;
      while (i > 0) {
        s += bit[i];
        i -= i & -i;
      }
      return s;
    }

    // bit[i] += x
    BitSum(int n) {
      MAXN = n;
      bit.resize(n+1);
    }

public: void add(int i, long long x) {
      while (i <= MAXN) {
        bit[i] += x;
        i += i & -i;
      }
    }

public: void reset() {
      for(int i=0; i<=MAXN; i++) {
        bit.at(i) = 0;
      }
    }

    // return the smallest i where sum(i) >= val
    // If sum(MAXN) < val, return INT_MAX
public: int lower_bound(long long val) {
      int min = 0;
      int max = MAXN;
      if (sum(max) < val) return INT_MAX;
      if (sum(0) >= val) return 0;
      while(min + 1 < max) {
        int now = (min+max)/2;
        if (sum(now) >= val) {
          max = now;
        } else {
          min = now;
        }
      }
      return max;
    }
};


class ERotate3x3 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<vector<int>> vec(3, vector<int>(n));
      rep(i, 3) {
        rep(j, n) {
          cin >> vec[i][j];
          vec[i][j]--;
        }
      }
      rep(j, n) {
        if (vec[1][j]%3 != 1) {
          cout << "No" << endl;
          return;
        }
        int a = vec[0][j]/3;
        int b = vec[1][j]/3;
        int c = vec[2][j]/3;
        if (a != b || b != c || c != a) {
          cout << "No" << endl;
          return;
        }
        if (b%2 != j%2) {
          cout << "No" << endl;
          return;
        }
      }

      ll even = 0;
      ll odd = 0;
      vector<int> ev, ov;

      rep(j, n) {
        int a = vec[0][j]%3;
        if (a != 0) {
          if (j%2 == 0) {
            even++;
          } else {
            odd++;
          }
        }
        int b = vec[0][j]/3;
        if (j%2 == 0) {
          ev.push_back(b);
        } else {
          ov.push_back(b);
        }
      }

      auto seg = BitSum(n);
      reverse(all(ev)); reverse(all(ov));
      for(auto e: ev) {
        odd += seg.sum(e+1);
        seg.add(e+1, 1);
      }
      seg.reset();
      for(auto e: ov) {
        even += seg.sum(e+1);
        seg.add(e+1, 1);
      }

      even %= 2; odd %= 2;
      if (even == 0 && odd == 0) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }

    }
};

signed main() {
  ERotate3x3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 2948