#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int a[3][N], f[N];
bool rev[2];

int main(int argc, char const *argv[]) {
  int n = read();
  for (int i = 1; i <= n; ++ i) {
    a[0][i] = read();
  }
  for (int i = 1; i <= n; ++ i) {
    a[1][i] = read();
  }
  for (int i = 1; i <= n; ++ i) {
    a[2][i] = read();
  }

  for (int i = 1; i <= n; ++ i) {
    if (a[1][i] % 3 != 2 || abs(a[0][i] - a[1][i]) > 1
        || abs(a[2][i] - a[1][i]) > 1) {
      return puts("No"), 0;
    }
    f[i] = a[1][i] / 3 + 1;

    if ((f[i] & 1) != (i & 1)) {
      return puts("No"), 0;
    }

    if (a[0][i] > a[1][i]) {
      rev[f[i] & 1] ^= 1;
    }
  }

  for (int i = 1; i <= n; ++ i) {
    while (f[i] != i) {
      rev[i&1^1] ^= 1;
      swap(f[i], f[f[i]]);
    }
  }

  if (rev[0] || rev[1]) {
    puts("No");
  } else {
    puts("Yes");
  }

  return 0;
}
/*

将每一列变成 x/3+1，如果是倒序则加个负号。

一次操作可以看做：

1 2 3 4 5 -> -3 -2 -1 4 5

let's do some buffs

[ 1  2  3] 4  5
 -3 -2[-1  4  5]
[-3 -2 -5]-4  1
  5  2[ 3 -4  1]
[ 5  2 -1] 4 -3
  1 -2[-5  4 -3]
  1 -2  3 -4  5


*/
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int mat[4][N], val[N], n, num[2], v[N];
void add(int x, int val) {
	for (; x <= n; x += ((x) & (-(x))))
		v[x] += val;
}
int query(int x) {
	int ret = 0;
	for (; x; x -= ((x) & (-(x))))
		ret += v[x];
	return ret;
}
void fail() {
	puts("No");
	exit(0);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 3; ++i)
		for (int j = 1; j <= n; ++j)
			scanf("%d", &mat[i][j]);
	for (int i = 1; i <= n; ++i) {
		if (mat[1][i] % 3 == 0) {
			if (mat[2][i] == mat[1][i] - 1 && mat[3][i] == mat[1][i] - 2)
				val[i] = -mat[1][i] / 3;
			else fail();
		}
		else if (mat[3][i] % 3 == 0) {
			if (mat[2][i] == mat[3][i] - 1 && mat[1][i] == mat[3][i] - 2)
				val[i] = mat[3][i] / 3;
			else fail();
		}
		else fail();
	}
	for (int i = 1; i <= n; i += 2) {
		if (val[i] < 0) num[1] ^= 1, val[i] = -val[i];
		if (val[i] % 2 == 0) fail();
	}
	for (int i = 2; i <= n; i += 2) {
		if (val[i] < 0) num[0] ^= 1, val[i] = -val[i];
		if (val[i] & 1) fail();
	}
	for (int i = 1; i <= n; i += 2) {
		if ((query(n) - query(val[i])) & 1) num[0] ^= 1;
		add(val[i], 1);
	}
	memset(v, 0, sizeof v);
	for (int i = 2; i <= n; i += 2) {
		if ((query(n) - query(val[i])) & 1) num[1] ^= 1;
		add(val[i], 1);
	}
	if ((!num[0]) && (!num[1]))
		puts("Yes");
	else puts("No");
	return 0;
}