{"trustable":false,"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":"MD","content":"数论之神LYD发明了一个数列F(n),其中F(1)\u003dA,F(2)\u003dB,F(n)\u003dC*F(n-2)+D\\*F(n-1)+P/n,此处的‘/’为整数除法且向下取整。现在,他给你出了一道简单题:求该数列的第n项。"}},{"title":"Input","value":{"format":"MD","content":"多组数据,每组数据包含6个整数A,B,C,D,P,n(0\u003c\u003dA,B,C,D\u003c\u003d1e9,1\u003c\u003dp,n\u003c\u003d1e9),意义如上。"}},{"title":"Output","value":{"format":"MD","content":"每组数据输出一个整数,表示答案mod 1e9+7的的结果。"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e1\n3 2 2 2 1 4\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e\n24\u003c/pre\u003e"}}]}