{"problem":{"name":"Triple Shift","description":{"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)$. You can repeat the following operation any number of times. *   Choose an integer $i$ ($1 \\l","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc136_b"},"statements":[{"statement_type":"Markdown","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$.\n\n## Constraints\n\n*   $3 \\leq N \\leq 5000$\n*   $1 \\leq A_i,B_i \\leq 5000$\n*   All values in input are integers.\n\n## Input\n\nInput 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$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc136_b","tags":[],"sample_group":[["4\n3 1 4 5\n4 1 5 3","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)$."],["3\n1 2 2\n2 1 2","Yes"],["3\n1 2 3\n2 3 4","No"]],"created_at":"2026-03-03 11:01:13"}}