{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eA seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Seven segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.\u003c/p\u003e\u003cp\u003eEdward, a student in Marjar University, is studying the course \"Logic and Computer Design Fundamentals\" this semester. He bought an eight-digit seven segment display component to make a hexadecimal counter for his course project.\u003c/p\u003e\u003cp\u003eIn order to display a hexadecimal number, the seven segment display component needs to consume some electrical energy. The total energy cost for display a hexadecimal number on the component is the sum of the energy cost for displaying each digit of the number. Edward found the following table on the Internet, which describes the energy cost for display each kind of digit.\u003c/p\u003e\n\n\u003ccenter\u003e\n\u003ctable\u003e\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003e\u003ctable border\u003d\"1\" style\u003d\"font-size: 14px; text-align: center; margin: 5px;\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\u003cth\u003eDigit\u003c/th\u003e\u003cth\u003eEnergy Cost\u003cbr\u003e(units/s)\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e0\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e1\u003c/td\u003e\u003ctd\u003e2\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e2\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e3\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e4\u003c/td\u003e\u003ctd\u003e4\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e5\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e6\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e7\u003c/td\u003e\u003ctd\u003e3\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\n\n\u003ctd\u003e\u003ctable border\u003d\"1\" style\u003d\"font-size: 14px; text-align: center; margin: 5px;\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\u003cth\u003eDigit\u003c/th\u003e\u003cth\u003eEnergy Cost\u003cbr\u003e(units/s)\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e8\u003c/td\u003e\u003ctd\u003e7\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e9\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eA\u003c/td\u003e\u003ctd\u003e6\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eB\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eC\u003c/td\u003e\u003ctd\u003e4\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eD\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eE\u003c/td\u003e\u003ctd\u003e5\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eF\u003c/td\u003e\u003ctd\u003e4\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\n\n\u003ctd\u003e\u003ctable border\u003d\"0\" style\u003d\"text-align: center\"\u003e\n\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/f7e020394075b8fe0e5a0100bb0ee6fe?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/7800b07d816fded975d3eda1022b680b?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/5db38c8a441ca548f75c6ab43717af68?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/2f6a2c6c66e29102442823118ca6f7d3?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/706a87a246b13e54520351badbb2bb87?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/be2f9e9ae6bf92e896a909bc1a0b5a20?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/002ec16e398550e488f9e8a48d305556?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/78fd4c1e953bb821a1ea712360395eea?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/8a14c891d1ebbfd80d252a99156e650e?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/08d567a96bea66e15268b692e6cc9236?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/98a43b115c453d1075aed2e9aea6b9e6?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/50e84b87fb020010f0382b8b75fb105f?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/43481fab981aa18e4232418ca766d84d?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/d956e84caa65dc41ae4106a938ae7606?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/e6f00c22e9f971e13feefb630b65a47e?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003ctd\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/9e9eb4c0c08bedd01a1f998d2f1b9288?v\u003d1714488836\" width\u003d\"38px\" height\u003d\"64px\"\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\n\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\n\u003c/center\u003e\n\n\u003cp\u003eFor example, in order to display the hexadecimal number \"5A8BEF67\" on the component for one second, 5 + 6 + 7 + 5 + 5 + 4 + 6 + 3 \u003d 41 units of energy will be consumed.\u003c/p\u003e\n\n\u003cp\u003eEdward\u0027s hexadecimal counter works as follows:\u003c/p\u003e\n\n\u003cul type\u003d\"disc\"\u003e\n\u003cli\u003e The counter will only work for \u003cvar\u003en\u003c/var\u003e seconds. After \u003cvar\u003en\u003c/var\u003e seconds the counter will stop displaying. \u003c/li\u003e\n\u003cli\u003e At the beginning of the 1st second, the counter will begin to display a previously configured eight-digit hexadecimal number \u003cvar\u003em\u003c/var\u003e. \u003c/li\u003e\n\u003cli\u003e At the end of the \u003cvar\u003ei\u003c/var\u003e-th second (1 ≤ \u003cvar\u003ei\u003c/var\u003e \u0026lt; \u003cvar\u003en\u003c/var\u003e), the number displayed will be increased by 1. If the number displayed will be larger than the hexadecimal number \"FFFFFFFF\" after increasing, the counter will set the number to 0 and continue displaying. \u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cp\u003eGiven \u003cvar\u003en\u003c/var\u003e and \u003cvar\u003em\u003c/var\u003e, Edward is interested in the total units of energy consumed by the seven segment display component. Can you help him by working out this problem?\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\n\u003cp\u003eThere are multiple test cases. The first line of input contains an integer \u003cvar\u003eT\u003c/var\u003e (1 ≤ \u003cvar\u003eT\u003c/var\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e), indicating the number of test cases. For each test case:\u003c/p\u003e\n\n\u003cp\u003eThe first and only line contains an integer \u003cvar\u003en\u003c/var\u003e (1 ≤ \u003cvar\u003en\u003c/var\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e9\u003c/sup\u003e) and a capitalized eight-digit hexadecimal number \u003cvar\u003em\u003c/var\u003e (00000000 ≤ \u003cvar\u003em\u003c/var\u003e ≤ FFFFFFFF), their meanings are described above.\u003c/p\u003e\n\n\u003cp\u003eWe kindly remind you that this problem contains large I/O file, so it\u0027s recommended to use a faster I/O method. For example, you can use scanf/printf instead of cin/cout in C++.\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\n\u003cp\u003eFor each test case output one line, indicating the total units of energy consumed by the eight-digit seven segment display component.\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\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\u003e3\n5 89ABCDEF\n3 FFFFFFFF\n7 00000000\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e208\n124\n327\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eHint\u003c/h4\u003e\n\n\u003cp\u003eFor the first test case, the counter will display 5 hexadecimal numbers (89ABCDEF, 89ABCDF0, 89ABCDF1, 89ABCDF2, 89ABCDF3) in 5 seconds. The total units of energy cost is (7 + 6 + 6 + 5 + 4 + 5 + 5 + 4) + (7 + 6 + 6 + 5 + 4 + 5 + 4 + 6) + (7 + 6 + 6 + 5 + 4 + 5 + 4 + 2) + (7 + 6 + 6 + 5 + 4 + 5 + 4 + 5) + (7 + 6 + 6 + 5 + 4 + 5 + 4 + 5) \u003d 208.\u003c/p\u003e\n\n\u003cp\u003eFor the second test case, the counter will display 3 hexadecimal numbers (FFFFFFFF, 00000000, 00000001) in 3 seconds. The total units of energy cost is (4 + 4 + 4 + 4 + 4 + 4 + 4 + 4) + (6 + 6 + 6 + 6 + 6 + 6 + 6 + 6) + (6 + 6 + 6 + 6 + 6 + 6 + 6 + 2) \u003d 124.\u003c/p\u003e\n"}}]}