{"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\"\u003eAs we all know, computer uses binary code to compute. Each decimal digit can be represented by a string of 0/1:\u003cbr\u003e\u003cbr\u003eDecimal\u0026nbsp;\u0026nbsp;0\u0026nbsp;\u0026nbsp;1\u0026nbsp;\u0026nbsp;2\u0026nbsp;\u0026nbsp;3\u0026nbsp;\u0026nbsp;4\u0026nbsp;\u0026nbsp;5\u0026nbsp;\u0026nbsp;6\u0026nbsp;\u0026nbsp;7\u0026nbsp;\u0026nbsp;8\u0026nbsp;\u0026nbsp;9\u003cbr\u003e Binary\u0026nbsp;\u0026nbsp;0\u0026nbsp;\u0026nbsp;1\u0026nbsp;\u0026nbsp;10\u0026nbsp;\u0026nbsp;11\u0026nbsp;\u0026nbsp;100\u0026nbsp;\u0026nbsp;101\u0026nbsp;\u0026nbsp;110\u0026nbsp;\u0026nbsp;111\u0026nbsp;\u0026nbsp;1000\u0026nbsp;\u0026nbsp;1001\u003cbr\u003e\u003cbr\u003eWe are going to transfer all the integers from L to R, both inclusive, with each decimal digit to binary. For example, after transferring decimal integer 127 to our binary representation, we can get 110111, because 1 is 1, 2 is 10 and 7 is 111. Happily, we find that n continuous bits s[i] have values v[i] associated with them. For a decimal number, after transferring to binary, if s[i] appears in it for k times, the value of if will be added k*v[i]. Now we want you to calculate the sum of value for each integer from L to R.\u003cbr\u003eSince the answer may be very large, you just need to output it mod 1000000007.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains a single integer T denoting the number of test cases.\u003cbr\u003eFor each test case, the first line contains a single integer n denoting the number of valuable continuous bits.\u003cbr\u003eThen comes n lines, each line has a string s contains only 0 and 1 and an integer v denoting the value.\u003cbr\u003eThe last line has two integers L and R."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a single integer—the sum of value for each integer from L and R."}},{"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\n2\r\n010 2\r\n101 3\r\n1 20\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eT\u0026lt;\u003d10\u003cbr\u003en\u0026lt;\u003d100,length(s)\u0026lt;\u003d100,val\u0026lt;\u003d100\u003cbr\u003eL\u0026lt;\u003dR\u0026lt;\u003d10^100\u003cbr\u003e"}}]}