{"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\u003ePathfinding is a task of finding a route between two points. It often appears in many problems. For example, in a GPS navigation software where a driver can query for a suggested route, or in a robot motion planning where it should find a valid sequence of movements to do some tasks, or in a simple maze solver where it should find a valid path from one point to another point. This problem is related to solving a maze.\u003c/p\u003e\u003cp\u003eThe maze considered in this problem is in the form of a matrix of integers $$$A$$$ of $$$N \\times N$$$. The value of each cell is generated from a given array $$$R$$$ and $$$C$$$ of $$$N$$$ integers each. Specifically, the value on the $$$i^{th}$$$ row and $$$j^{th}$$$ column, cell $$$(i,j)$$$, is equal to $$$R_i + C_j$$$. Note that all indexes in this problem are from $$$1$$$ to $$$N$$$.\u003c/p\u003e\u003cp\u003eA path in this maze is defined as a sequence of cells $$$(r_1,c_1), (r_2,c_2), \\dots, (r_k,c_k)$$$ such that $$$|r_i - r_{i+1}| + |c_i - c_{i+1}| \u003d 1$$$ for all $$$1 \\le i \u0026lt; k$$$. In other words, each adjacent cell differs only by $$$1$$$ row or only by $$$1$$$ column. An \u003cspan class\u003d\"tex-font-style-bf\"\u003eeven path\u003c/span\u003e in this maze is defined as a path in which all the cells in the path contain only even numbers.\u003c/p\u003e\u003cp\u003eGiven a tuple $$$\\langle r_a,c_a,r_b,c_b \\rangle$$$ as a query, your task is to determine whether there exists an even path from cell $$$(r_a,c_a)$$$ to cell $$$(r_b,c_b)$$$. To simplify the problem, it is guaranteed that both cell $$$(r_a,c_a)$$$ and cell $$$(r_b,c_b)$$$ contain even numbers.\u003c/p\u003e\u003cp\u003eFor example, let $$$N \u003d 5$$$, $$$R \u003d \\{6, 2, 7, 8, 3\\}$$$, and $$$C \u003d \\{3, 4, 8, 5, 1\\}$$$. The following figure depicts the matrix $$$A$$$ of $$$5 \\times 5$$$ which is generated from the given array $$$R$$$ and $$$C$$$.\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/31f4a1f45163cc76d8f25044821b3859?v\u003d1715965402\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003eLet us consider several queries: \u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$\\langle 2, 2, 1, 3 \\rangle$$$: There is an even path from cell $$$(2,2)$$$ to cell $$$(1,3)$$$, e.g., $$$(2,2), (2,3), (1,3)$$$. Of course, $$$(2,2), (1,2), (1,3)$$$ is also a valid even path. \u003c/li\u003e\u003cli\u003e $$$\\langle 4, 2, 4, 3 \\rangle$$$: There is an even path from cell $$$(4,2)$$$ to cell $$$(4,3)$$$, namely $$$(4,2), (4,3)$$$. \u003c/li\u003e\u003cli\u003e $$$\\langle 5, 1, 3, 4 \\rangle$$$: There is no even path from cell $$$(5,1)$$$ to cell $$$(3,4)$$$. Observe that the only two neighboring cells of $$$(5,1)$$$ are cell $$$(5,2)$$$ and cell $$$(4,1)$$$, and both of them contain odd numbers (\u003cspan class\u003d\"tex-font-style-tt\"\u003e7\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003e11\u003c/span\u003e, respectively), thus, there cannot be any even path originating from cell $$$(5,1)$$$. \u003c/li\u003e\u003c/ul\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eInput begins with a line containing two integers: $$$N$$$ $$$Q$$$ ($$$2 \\le N \\le 100\\,000$$$; $$$1 \\le Q \\le 100\\,000$$$) representing the size of the maze and the number of queries, respectively. The next line contains $$$N$$$ integers: $$$R_i$$$ ($$$0 \\le R_i \\le 10^6$$$) representing the array $$$R$$$. The next line contains $$$N$$$ integers: $$$C_i$$$ ($$$0 \\le C_i \\le 10^6$$$) representing the array $$$C$$$. The next $$$Q$$$ lines each contains four integers: $$$r_a$$$ $$$c_a$$$ $$$r_b$$$ $$$c_b$$$ ($$$1 \\le r_a, c_a, r_b, c_b \\le N$$$) representing a query of $$$\\langle r_a, c_a, r_b, c_b \\rangle$$$. It is guaranteed that $$$(r_a,c_a)$$$ and $$$(r_b,c_b)$$$ are two different cells in the maze and both of them contain even numbers.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each query in the same order as input, output in a line a string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" (without quotes) or \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" (without quotes) whether there exists an even path from cell $$$(r_a,c_a)$$$ to cell $$$(r_b,c_b)$$$.\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\n6 2 7 8 3\n3 4 8 5 1\n2 2 1 3\n4 2 4 3\n5 1 3 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nNO\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e3 2\n30 40 49\n15 20 25\n2 2 3 3\n1 2 2 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eNO\nYES\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eExplanation for the sample input/output #1\u003c/span\u003e\u003c/p\u003e\u003cp\u003eThis is the example from the problem description.\u003c/p\u003e"}}]}