{"trustable":false,"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":"这道题很简单,让你求幂塔。\u003cbr\u003e\n可能有人对幂塔不是很熟悉,比如数列[a,b,c,d],他对应的幂塔就是a^(b^(c^d)),这时,^代表幂的意思。\u003cbr\u003e\n(但是,很不幸,这道题目卡常,其实我也不想卡,但是数据就这样。。。)"}},{"title":"Input","value":{"format":"HTML","content":"第一行一个整数n(1\u003c\u003dn\u003c\u003d100000)和m(1\u003c\u003dm\u003c\u003d1000000000),n代表数列长度,m代表最终答案的模数。\u003cbr\u003e\n第二行n个数字,均小于1e9,代表给定的数列。\u003cbr\u003e\n第三行一个整数q(1\u003c\u003dq\u003c\u003d100000),代表q组询问。\u003cbr\u003e\n对于每组询问,输入两个整数L,R。输出第L到第R的数列对应的幂塔模m的值。"}},{"title":"Output","value":{"format":"HTML","content":"对于每组询问,输出一行,代表数列L到R,对应的幂塔模m的值。"}},{"title":"样例输入1","value":{"format":"HTML","content":"6 1000000000\u003cbr\u003e\n1 2 2 3 3 3\u003cbr\u003e\n8\u003cbr\u003e\n4 4\u003cbr\u003e\n4 5\u003cbr\u003e\n4 6\u003cbr\u003e\n1 1\u003cbr\u003e\n1 6\u003cbr\u003e\n2 2\u003cbr\u003e\n2 3\u003cbr\u003e\n2 4"}},{"title":"样例输出1","value":{"format":"HTML","content":"3\u003cbr\u003e\n27\u003cbr\u003e\n597484987\u003cbr\u003e\n1\u003cbr\u003e\n1\u003cbr\u003e\n2\u003cbr\u003e\n4\u003cbr\u003e\n256"}},{"title":"样例输入2","value":{"format":"HTML","content":"10 20\u003cbr\u003e\n792708224 4633945 600798790 384332600 283309209 762285205 750900274 160512987 390669628 205259431\u003cbr\u003e\n10\u003cbr\u003e\n5 9\u003cbr\u003e\n10 10\u003cbr\u003e\n8 10\u003cbr\u003e\n7 10\u003cbr\u003e\n7 10\u003cbr\u003e\n10 10\u003cbr\u003e\n4 4\u003cbr\u003e\n10 10\u003cbr\u003e\n7 7\u003cbr\u003e\n4 8"}},{"title":"样例输出2","value":{"format":"HTML","content":"9\u003cbr\u003e\n11\u003cbr\u003e\n1\u003cbr\u003e\n4\u003cbr\u003e\n4\u003cbr\u003e\n11\u003cbr\u003e\n0\u003cbr\u003e\n11\u003cbr\u003e\n14\u003cbr\u003e\n0"}}]}