{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eTerraced fields with beautiful landscapes in Northwest\n Vietnam are popular destinations for tourists. At each terraced\n field selected as a tourist attraction, the local authorities\n build a staircase alongside the terraced field. The steps are\n numbered from \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e starting from the\n bottom of the hill. At steps divisible by \u003cspan class\u003d\"tex2jax_process\"\u003e$8$\u003c/span\u003e (i.e. steps numbered \u003cspan class\u003d\"tex2jax_process\"\u003e$8, 16, 24$\u003c/span\u003e, etc.) and at the final\n step (i.e. \u003cspan class\u003d\"tex2jax_process\"\u003e${n}^\\textrm\n {th}$\u003c/span\u003e step), the step number is stone engraved as a\n height indication for tourists. The digits \u003cspan class\u003d\"tex2jax_process\"\u003e$6$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$8$\u003c/span\u003e are considered lucky, so people\n used a precious stone to specifically engrave these digits.\u003c/p\u003e\n \u003cp\u003eThere is a tour that goes to a terraced field having\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e steps. The price of\n the tour is the number of precious stone engraved digits on its\n steps.\u003c/p\u003e\n \u003cp\u003eFor given \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e, your\n task is to determine the price of the tour.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eThe input consists of several datasets. The first line of\n the input contains the number of datasets, which is a positive\n number and is not greater than \u003cspan class\u003d\"tex2jax_process\"\u003e$100\\, 000$\u003c/span\u003e. The following lines\n describe the datasets.\u003c/p\u003e\n \u003cp\u003eEach dataset is described by one line containing an integer\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e \u003cspan class\u003d\"tex2jax_process\"\u003e$(1\u0026lt;n \\leq {10}^{18})$\u003c/span\u003e.\u003c/p\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eFor each dataset, output the price of the tour.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e4\n9\n32\n56\n18\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n2\n4\n3\n\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}