{"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\"\u003eDefine f(n) as the number of ways to perform n in format of the sum of some positive integers. For instance, when n\u003d4, we have\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d1+1+1+1\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d1+1+2\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d1+2+1\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d2+1+1\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d1+3\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d2+2\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d3+1\u003cbr\u003e\u0026nbsp;\u0026nbsp;4\u003d4\u003cbr\u003etotally 8 ways. Actually, we will have f(n)\u003d2\u003csup\u003e(n-1)\u003c/sup\u003e after observations.\u003cbr\u003eGiven a pair of integers n and k, your task is to figure out how many times that the integer k occurs in such 2\u003csup\u003e(n-1)\u003c/sup\u003e ways. In the example above, number 1 occurs for 12 times, while number 4 only occurs once.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer T(1≤T≤10000), indicating the number of test cases.\u003cbr\u003eEach test case contains two integers n and k(1≤n,k≤10\u003csup\u003e9\u003c/sup\u003e).\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output the required answer modulo 10\u003csup\u003e9\u003c/sup\u003e+7 for each test case, one per 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\n4 2\r\n5 5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}