{"raw_statement":[{"iden":"problem statement","content":"You are given integer sequences of length $N$ each: $A=(A_1,A_2,\\cdots,A_N)$ and $B=(B_1,B_2,\\cdots,B_N)$.\nYou can repeat the following operation any number of times.\n\n*   Choose an integer $i$ ($1 \\leq i \\leq N-2$) and let $x,y,z$ be the current values of $A_i,A_{i+1},A_{i+2}$, respectively. Then, replace the values of $A_i,A_{i+1},A_{i+2}$ with $z,x,y$, respectively.\n\nDetermine whether it is possible to make $A$ equal $B$."},{"iden":"constraints","content":"*   $3 \\leq N \\leq 5000$\n*   $1 \\leq A_i,B_i \\leq 5000$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\cdots$ $A_N$\n$B_1$ $B_2$ $\\cdots$ $B_N$"},{"iden":"sample input 1","content":"4\n3 1 4 5\n4 1 5 3"},{"iden":"sample output 1","content":"Yes\n\nWe should do the following.\n\n*   Initially, we have $A=(3,1,4,5)$.\n*   Do the operation with $i=1$, making $A=(4,3,1,5)$.\n*   Do the operation with $i=2$, making $A=(4,5,3,1)$.\n*   Do the operation with $i=2$, making $A=(4,1,5,3)$."},{"iden":"sample input 2","content":"3\n1 2 2\n2 1 2"},{"iden":"sample output 2","content":"Yes"},{"iden":"sample input 3","content":"3\n1 2 3\n2 3 4"},{"iden":"sample output 3","content":"No"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}