{"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\"\u003e QSC dream of becoming a mathematician, he believes that everything in this world has a mathematical law.\u003cbr\u003e\u003cbr\u003e Through unremitting efforts, one day he finally found the QSC sequence, it is a very magical sequence, can be calculated by a series of calculations to predict the results of a course of a semester of a student.\u003cbr\u003e\u003cbr\u003e This sequence is such like that, first of all,$f(0)\u003d0,f(1)\u003d1,f(n)\u003df(n-2)+2*f(n-1)(n\\geq 2)$Then the definition of the QSC sequence is $g(n)\u003d\\sum_{i\u003d0}^{n}f(i)^2$. If we know the birthday of the student is n, the year at the beginning of the semester is y, the course number x and the course total score s, then the forecast mark is $x^{g(n*y)}\\%(s+1)$.\u003cbr\u003e QSC sequence published caused a sensation, after a number of students to find out the results of the prediction is very accurate, the shortcoming is the complex calculation. As clever as you are, can you write a program to predict the mark?\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line is an integer T(1≤T≤1000).\u003cbr\u003e\u003cbr\u003eThe next T lines were given n, y, x, s, respectively.\u003cbr\u003e\u003cbr\u003en、x is 8 bits decimal integer, for example, 00001234.\u003cbr\u003e\u003cbr\u003ey is 4 bits decimal integer, for example, 1234.\u003cbr\u003en、x、y are not negetive.\u003cbr\u003e\u003cbr\u003e 1≤s≤100000000"}},{"title":"Output","value":{"format":"HTML","content":"For each test case the output is only one integer number ans in a line."}},{"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\r\n20160830 2016 12345678 666\r\n20101010 2014 03030303 333\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n317\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}