//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    struct BIT
    {
        int bit[N];BIT(){memset(bit,0,sizeof bit);}
        int lowbit(int x){return x&-x;}
        void add(int x,int c){while(x<N)bit[x]+=c,x+=lowbit(x);}
        int ask(int x){int ans=0;while(x>=1)ans+=bit[x],x-=lowbit(x);return ans;}
    }bit[2];
    int fm[3][N];int getid(int num){return 1+(num-1)/3;}
    void gg(){puts("No");exit(0);}
    int inv[2],flip[2];
	void main()
	{
        int n=qread();fo(op,0,2) fo(i,1,n) fm[op][i]=qread();
        fo(i,1,n)
        {
            if(getid(fm[0][i])!=getid(fm[1][i]) or getid(fm[1][i])!=getid(fm[2][i])) gg();
            bool x=fm[0][i]<fm[1][i] and fm[1][i]<fm[2][i],y=fm[0][i]>fm[1][i] and fm[1][i]>fm[2][i];
            if(!x and !y) gg();flip[i&1]+=y;
            int id=getid(fm[0][i]);if((id&1)^(i&1)) gg();
            inv[i&1]+=bit[i&1].ask(n-id+1),bit[i&1].add(n-id+1,1);
        }
        if((inv[0]&1)^(flip[1]&1) or (inv[1]&1)^(flip[0]&1)) gg();
        puts("Yes");
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}

//IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 4 * 100 * 1000 + 17;

int n, a[4][MAXN], b[4][MAXN], p[MAXN], q[MAXN], fen[MAXN];
vector<int> v[2];

void add(int x) {
	for (; x <= n; x += x & (-x))
		fen[x]++;
}
int get(int x) {
	int res = 0;
	for (; x; x -= x & (-x))
		res += fen[x];
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= 3; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j], b[i][j] = j * 3 + i - 3, p[b[i][j]] = j, q[b[i][j]] = i;
	for (int j = 1; j <= n; j++) {
		if (p[a[1][j]] != p[a[2][j]] || p[a[2][j]] != p[a[3][j]] || q[a[2][j]] != 2 || p[a[1][j]] % 2 != j % 2)
			return cout << "No" << endl, 0;
		v[j % 2].pb(j);
	}
	for (int k = 0; k < 2; k++) {
		int inv = 0;
		for (int i = v[k].size() - 1; i >= 0; i--)
			(inv += get(p[a[1][v[k][i]]])) %= 2, add(p[a[1][v[k][i]]]);
		int up = 0;
		for (int i = 0; i < v[1 - k].size(); i++)
			if (a[1][v[1 - k][i]] % 3 == 0)
				up++;
		if (up % 2 != inv % 2)
			return cout << "No" << endl, 0;
		for (int i = 1; i <= n; i++)
			fen[i] = 0;
	}
	cout << "Yes" << endl;
	return 0;
}
