{"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,a palindrome number is the number which reads the same backward as forward,such as 666 or 747.Some numbers are not the palindrome numbers in decimal form,but in other base,they may become the palindrome number.Like 288,it’s not a palindrome number under 10-base.But if we convert it to 17-base number,it’s GG,which becomes a palindrome number.So we define an interesting function f(n,k) as follow:\u003cbr\u003ef(n,k)\u003dk if n is a palindrome number under k-base.\u003cbr\u003eOtherwise f(n,k)\u003d1.\u003cbr\u003eNow given you 4 integers L,R,l,r,you need to caluclate the mathematics expression $ \\sum_{i\u003dL}^{R}\\sum_{j\u003dl}^{r}f(i,j) $ .\u003cbr\u003eWhen representing the k-base(k\u0026gt;10) number,we need to use A to represent 10,B to represent 11,C to repesent 12 and so on.The biggest number is Z(35),so we only discuss about the situation at most 36-base number.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line consists of an integer T,which denotes the number of test cases.\u003cbr\u003eIn the following T lines,each line consists of 4 integers L,R,l,r.\u003cbr\u003e($ 1 \\leq T \\leq 10^5, 1 \\leq L \\leq R \\leq 10^9, 2 \\leq l \\leq r \\leq 36$)"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output the answer in the form of “Case #i: ans” in a seperate 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\u003e3\r\n1 1 2 36\r\n1 982180 10 10\r\n496690841 524639270 5 20\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 665\r\nCase #2: 1000000\r\nCase #3: 447525746\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}