#include bool solve(std::vector A) { const int N = (int)A.size() / 2; bool ans = false; for (int s = 0; s < 2 * N; ++s) { for (int t = 0; t < 2 * N; ++t) { std::vector x, y; int i = s; while ((int)x.size() < N) { x.push_back(A[i]); i = (i + 1) % (2 * N); } i = t; while ((int)y.size() < N) { y.push_back(A[i]); i = (i - 1 + 2 * N) % (2 * N); } bool mans = true; for (int i = 0; i < N; ++i) { if (x[i] != -1 and y[i] != -1 and x[i] != y[i]) mans = false; } ans |= mans; } } return ans; } int main() { int N; std::cin >> N; std::vector A(2 * N); for (auto &e : A) std::cin >> e; const auto res = solve(A); std::cout << (res ? "Yes" : "No") << std::endl; }