#include <bits/stdc++.h>

using namespace std;

const int maxn = 100010;

int lowbit(int x) {
	return x & (-x);
}

int n, a[maxn][5], mn[maxn];
int s0[maxn], s1[maxn]; // 1 ~ n

void add(int *s, int p) {
	for (int i = p; i <= n; i += lowbit(i)) {
		s[i] ^= 1;
	}
}

int ask(int *s, int p) {
	if (!p) return 0;
	int ret = 0;
	for (int i = p; i; i -= lowbit(i)) {
		ret ^= s[i];
	}
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) mn[i] = 3 * n;
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= n; j++) {
			scanf("%d", &a[j][i]);
			mn[j] = min(mn[j], a[j][i]);
		}
	}
	int ok = 1;
	for (int i = 1; i <= n; i++) {
		if ((i ^ mn[i]) & 1) {
			ok = 0;
		}
		if (a[i][2] != mn[i] + 1 || (a[i][3] != mn[i] + 2 && a[i][1] != mn[i] + 2)) {
			ok = 0;
		}
	}
	if (!ok) {
		puts("No");
		return 0;
	}
	int a0 = 0, a1 = 0, b0 = 0, b1 = 0;
	for (int i = 1; i <= n; i++) {
		if (mn[i] != a[i][1]) {
			if (i & 1) {
				a1 ^= 1;
			} else {
				a0 ^= 1;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		int t = (mn[i] + 2) / 3;
		if (i & 1) {
			b1 ^= ask(s1, n) ^ ask(s1, t);
			add(s1, t);
		} else {
			b0 ^= ask(s0, n) ^ ask(s0, t);
			add(s0, t);
		}
	}
	if ((a0 ^ b1) || (a1 ^ b0)) puts("No");
	else puts("Yes");
	return 0;
}