{"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":"Q老师 对数列有一种非同一般的热爱,尤其是优美的斐波那契数列。\n\n这一天,Q老师 为了增强大家对于斐波那契数列的理解,决定在斐波那契的基础上创建一个新的数列 f(x) 来考一考大家。数列 f(x) 定义如下:\n\n当 x \u003c 10 时,f(x) \u003d x;\n当 x ≥ 10 时,f(x) \u003d a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + ...... + a9 * f(x-10),ai 只能为 0 或 1。\n\nQ老师 将给定 a0~a9,以及两个正整数 k m,询问 f(k) % m 的数值大小。\n\n聪明的你能通过 Q老师 的考验吗?\n\n"}},{"title":"Input","value":{"format":"MD","content":"输出文件包含多组测试用例,每组测试用例格式如下:\n\n第一行给定两个正整数 k m。(k \u003c 2e9, m \u003c 1e5)\n\n第二行给定十个整数,分别表示 a0~a9。"}},{"title":"Output","value":{"format":"MD","content":"对于每一组测试用例输出一行,表示 f(k) % m 的数值大小。"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e10 9999\n1 1 1 1 1 1 1 1 1 1\n20 500\n1 0 1 0 1 0 1 0 1 0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e45\n104\u003c/pre\u003e"}}]}