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

const int M = 3, N = 1e5 + 100;

int n, fen[N], a[M][N];

void input() {
	cin >> n;
	for (int i = 0; i < M; i++)
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
			a[i][j]--;
		}
}

void NO() {
	cout << "No\n";
	exit(0);
}

void check_1() {
	for (int i = 0; i < n; i++)
		if (a[0][i] / 3 != a[1][i] / 3 || a[1][i] / 3 != a[2][i] / 3)
			NO();
}

void check_2() {
	for (int i = 0; i < n; i++)
		if (a[1][i] % 3 != 1)
			NO();
}

void check_3() {
	for (int i = 0; i < M; i++)
		for (int j = 0; j < n; j++)
			if (j % 2 != (a[i][j] / 3) % 2)
				NO();
}

void add(int x) {
	for (++x; x < N; x += x & -x)
		fen[x] ^= 1;
}

int get(int x) {
	int res = 0;
	for (; x; x ^= x & -x)
		res ^= fen[x];
	return res;
}

int inversion(vector<int> vec) {
	memset(fen, 0, sizeof fen);
	int res = 0;
	reverse(vec.begin(), vec.end());
	for (int x: vec) {
		res ^= get(x) & 1;
		add(x);
	}
	return res;
}

void check_4(int X, int Y) {
	vector<int> vec;
	for (int i = Y; i < n; i += 2)
		vec.push_back(a[0][i] / 3);
	int res = inversion(vec) & 1;
	for (int i = X; i < n; i += 2)
		res ^= (a[0][i] > a[2][i]);
	if (res)
		NO();
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	check_1();
	check_2();
	check_3();
	check_4(0, 1);
	check_4(1, 0);
	cout << "Yes\n";
}
