CSES - Aalto Competitive Programming 2024 - wk10 - Wed - Fishers
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There are nn fishers numbered 1,2,,n1,2,\dots,n scattered around a round lake. Each of the fishers has picked a fixed point on the shoreline and is casting their line to that exact direction. Check if there is a risk of the lines getting tangled up. Tangling may only happen when two lines cross each other.

The fishers and their line casting directions are represented in the array ff of 2n2n integers. If the ii-th integer of ff is XX then it means that position ii is occupied by fisher XX and if it is X-X then this is the point to which the fisher is casting their line. Positions ii and i+1i+1 are next to each other and as the lake is round, consider positions 2n2n and 11 to be next to each other also.

Input

The first line contains a single integer nn. The second line contains 2n2n integers f1,f2,,f2nf_1,\,f_2,\dots,\,f_{2n}.

Output

Print "Yes" if the lines might get tangled up and "No" otherwise.

Constraints

  • 1n1051 \leq n \leq 10^5
  • nfin-n \leq f_i \leq n
  • fi0f_i \neq 0
  • fifjf_i \neq f_j if iji \neq j

Example 1

Input:

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

Output:

Yes

Example 2

Input:

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

Output:

No