{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eEssa is playing Musical Chairs with his friends, Musical chairs, is a game of elimination involving players, chairs, and music, with one fewer chair than players.\u003c/p\u003e\u003cp\u003eWhen the song ends whichever player fails to sit on a chair is eliminated, with a chair then being removed and the process repeated until only one player remains.\u003c/p\u003e\u003cp\u003eAs we know Essa gets really competitive and will be willing to do anything to win, so he memorized each song\u0027s length in the playlist and the order they will be played. He also knows the order of the chairs that will be eliminated at the beginning of each turn, now at each beginning of a turn, Essa decides whether the group moves in clockwise or counterclockwise. \u003c/p\u003e\u003cp\u003eEach player changes their position after each second. The chairs will be used to form a circle, so if Essa chooses to move clockwise, each $$$i^{\\text{th}}$$$ player will move to $$$i+1$$$ position and the player at the last position will move to the first position. If Essa chooses to move counterclockwise, each $$$i^{\\text{th}}$$$ player will move to $$$i-1$$$ position, and the player at the first position will move to the last position. Given Essa\u0027s initial position, the length of each song and the order the chairs will be eliminated. Is there a way Essa can win?\u003c/p\u003e\u003cp\u003eNote that each time a chair is removed, the circle gets smaller.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line will contain 2 integers $$$n$$$ number of players ($$$2\\le n \\le 1000$$$) and $$$p$$$ Essa\u0027s initial position ($$$1\\le p \\le n$$$).\u003c/p\u003e\u003cp\u003eThe second line will contain $$$n-1$$$ integers, the length of the $$$i^{\\text{th}}$$$ song in seconds ($$$1\\le ai^{\\text{th}} \\le 10^9$$$).\u003c/p\u003e\u003cp\u003eThe third line will contain $$$n-1$$$ distinct integers $$$j^{\\text{th}}$$$ the order that the chairs will be eliminated ($$$1\\le aj^{\\text{th}} \\le n$$$).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eprint \"Yes\" without quotations if there\u0027s a way Essa can win, otherwise print \"No\" without quotations.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 3\n4 4 4 4\n4 3 2 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}