#include <bits/stdc++.h>

#define FOR(i, a, b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define YYS(x, arr) for(auto& x: arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9 + 7;

template<class T> T &chmin(T &a, const T &b){a = min(a, b);}
template<class T> T &chmax(T &a, const T &b){a = max(a, b);}
template<class T> void UNIQUE(vector<T> &a){a.erase(unique(a.begin(), a.end()), a.end());}

template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[10000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct BIT{
  vector<ll> bit;
  int size;
  void init(int n){
    size = 1;
    while(size < n){
      size *= 2;
    }
    bit.assign(size, 0);
  }
  void add(int k, ll v){
    for(int i = k + 1; i <= size; i += i & -i){
      bit[i-1] += v;
    }
  }
  ll sum(int k){
    ll res = 0;
    for(int i = k; i > 0; i -= i & -i){
      res += bit[i-1];
    }
    return res;
  }
};

void no(){
  puts("No");
  exit(0);
}

int main(){

  int n = in();
  vector<vector<int>> a(3, vector<int>(n));
  REP(i, 3){
    REP(j, n){
      a[i][j] = in();
    }
  }

  vector<int> b(n);
  vector<int> c(n);
  REP(i, n){
    if(a[0][i] % 3 == 1){
      if(a[1][i] == a[0][i] + 1 && a[2][i] == a[0][i] + 2){
        b[i] = a[2][i] / 3;
        c[i] = 0;
      } else {
        no();
      }
    } else if(a[2][i] % 3 == 1){
      if(a[1][i] == a[2][i] + 1 && a[0][i] == a[2][i] + 2){
        b[i] = a[0][i] / 3;
        c[i] = 1;
      } else {
        no();
      }
    } else {
      no();
    }
  }

  REP(i, n){
    if((b[i] + i) % 2 == 0){
      no();
    }
  }

  /*
  REP(i, n){
    if(b[i] == 1){
      if((i / 2 + c[i]) % 2 == 1){
        no();
      }
    }
    if(b[i] == n){
      if(((n - 1 - i) / 2 + c[i]) % 2 == 1){
        no();
      }
    }
  }
  */
  
  ll suma = 0;
  ll sumb = 0;
  REP(i, n){
    if(i % 2 == 0){
      suma += c[i];
    } else {
      sumb += c[i];
    }
  }

  // cout << b << endl;1
  // cout << c << endl;

  BIT bita, bitb;
  bita.init(n+1);
  bitb.init(n+1);
  REP(i, n){
    if(i % 2 == 0){
      sumb += bita.sum(n+1) - bita.sum(b[i]);
      bita.add(b[i], 1);
    } else {
      suma += bitb.sum(n+1) - bitb.sum(b[i]);
      bitb.add(b[i], 1);
    }
  }

  // if((suma + sumb) % 2 == 0){
  if(suma % 2 == 0 && sumb % 2 == 0){
    puts("Yes");
  } else {
    no();
  }
  
  // cout << b << endl;
  
  return 0;
}


Measured memory_bytes: 4228