{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eMonkey A lives on a tree, he always plays on this tree.\u003cbr\u003e\u003cbr\u003eOne day, monkey A learned about one of the bit-operations, xor. He was keen of this interesting operation and wanted to practise it at once.\u003cbr\u003e\u003cbr\u003eMonkey A gave a value to each node on the tree. And he was curious about a problem.\u003cbr\u003e\u003cbr\u003eThe problem is how large the xor result of number x and one node value of label y can be, when giving you a non-negative integer x and a node label u indicates that node y is in the subtree whose root is u(y can be equal to u).\u003cbr\u003e\u003cbr\u003eCan you help him?\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are no more than 6 test cases.\u003cbr\u003e\u003cbr\u003eFor each test case there are two positive integers n and q, indicate that the tree has n nodes and you need to answer q queries.\u003cbr\u003e\u003cbr\u003eThen two lines follow.\u003cbr\u003e\u003cbr\u003eThe first line contains n non-negative integers $V_1,V_2,\\cdots,V_n$, indicating the value of node i.\u003cbr\u003e\u003cbr\u003eThe second line contains n-1 non-negative integers $F_1,F_2,\\cdots\\,F_{n-1}$, $F_i$ means the father of node $i+1$.\u003cbr\u003e\u003cbr\u003eAnd then q lines follow.\u003cbr\u003e\u003cbr\u003eIn the i-th line, there are two integers u and x, indicating that the node you pick should be in the subtree of u, and x has been described in the problem.\u003cbr\u003e\u003cbr\u003e$2 \\leq n,q \\leq 10^5$\u003cbr\u003e\u003cbr\u003e$0 \\leq V_i \\leq 10^9$\u003cbr\u003e\u003cbr\u003e$1 \\leq F_i \\leq n$, the root of the tree is node 1.\u003cbr\u003e\u003cbr\u003e$1 \\leq u \\leq n,0 \\leq x \\leq 10^9$\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each query, just print an integer in a line indicating the largest result.\u003cbr\u003e"}},{"title":"Sample","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\u003e2 2\r\n1 2\r\n1\r\n1 3\r\n2 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}