{"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\"\u003e11 Dimensions is a cute contestant being talented in math. One day, 11 Dimensions came across a problem but didn\u0027t manage to solve it. Today you are taking training here, so 11 Dimensions turns to you for help.\u003cbr\u003e\u003cbr\u003eYou are given a decimal integer $S$ with $n$ bits $s_1s_2\\dots s_n(0\\leq s_i\\leq 9)$, but some bits can not be recognized now(replaced by ``$\\texttt{?}$\u0027\u0027). The only thing you know is that $S$ is a multiple of a given integer $m$.\u003cbr\u003e\u003cbr\u003eThere may be many possible values of the original $S$, please write a program to find the $k$-th smallest value among them. Note that you need to answer $q$ queries efficiently.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T(1\\leq T\\leq 10000)$, denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eIn each test case, there are three integers $n,m,q(1\\leq n\\leq 50000,2\\leq m\\leq 20,1\\leq q\\leq 100000)$ in the first line, denoting the length of $S$, the parameter $m$, and the number of queries.\u003cbr\u003e\u003cbr\u003eIn the second line, there is a string $s$ of length $n$, denoting the given decimal integer $S$. It is guaranteed that $s_i$ is either an integer within $[0,9]$ or ``$\\texttt{?}$\u0027\u0027, and $s_1$ is always an integer within $[1,9]$.\u003cbr\u003e\u003cbr\u003eFor the next $q$ lines, each line contains an integer $k_i(1\\leq k_i\\leq 10^{18})$, denoting each query.\u003cbr\u003e\u003cbr\u003eIt is guaranteed that $\\sum n\\leq 500000$ and $\\sum q\\leq 10^6$."}},{"title":"Output","value":{"format":"HTML","content":"For each query, print a single line containing an integer, denoting the value of $S$. If the answer exists, print $S\\bmod(10^9+7)$ instead, otherwise print ``$\\texttt{-1}$\u0027\u0027."}},{"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\u003e1\r\n5 5 5\r\n2??3?\r\n1\r\n2\r\n3\r\n100\r\n10000\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e20030\r\n20035\r\n20130\r\n24935\r\n-1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}