{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\u003cspan class\u003d\"tex-font-style-it\"\u003eIn this problem, unlike problem A, you need to look for \u003cspan class\u003d\"tex-font-style-bf\"\u003eunluckiest number\u003c/span\u003e, not the luckiest one.\u003c/span\u003e\u003c/p\u003e\u003cp\u003e\u003cspan class\u003d\"tex-font-style-bf\"\u003eNote that the constraints of this problem differ from such in problem A.\u003c/span\u003e\u003c/p\u003e\u003cp\u003eOlympus City recently launched the production of personal starships. Now everyone on Mars can buy one and fly to other planets inexpensively.\u003c/p\u003e\u003cp\u003eEach starship has a number\u0026nbsp;—some positive integer $$$x$$$. Let\u0027s define the \u003cspan class\u003d\"tex-font-style-it\"\u003eluckiness\u003c/span\u003e of a number $$$x$$$ as the difference between the largest and smallest digits of that number. For example, $$$142857$$$ has $$$8$$$ as its largest digit and $$$1$$$ as its smallest digit, so its luckiness is $$$8-1\u003d7$$$. And the number $$$111$$$ has all digits equal to $$$1$$$, so its luckiness is zero.\u003c/p\u003e\u003cp\u003eHateehc is a famous Martian blogger who often flies to different corners of the solar system. To release interesting videos even faster, he decided to buy himself a starship. When he came to the store, he saw starships with numbers from $$$l$$$ to $$$r$$$ inclusively. While in the store, Hateehc wanted to find a starship with the \u003cspan class\u003d\"tex-font-style-bf\"\u003eunluckiest\u003c/span\u003e number.\u003c/p\u003e\u003cp\u003eSince there are a lot of starships in the store, and Hateehc can\u0027t program, you have to help the blogger and write a program that answers his question.\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/b410c3c4c836cf26fbace907dcadeccb?v\u003d1726288593\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains an integer $$$t$$$ ($$$1 \\le t \\le 600$$$)\u0026nbsp;—the number of test cases.\u003c/p\u003e\u003cp\u003eEach of the following $$$t$$$ lines contains a description of the test case. The description consists of two integers $$$l$$$, $$$r$$$ ($$$1 \\le l \\le r \\le 10^{18}$$$)\u0026nbsp;— the largest and smallest numbers of the starships in the store.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint $$$t$$$ lines, one line for each test case, containing the unluckiest starship number in the store.\u003c/p\u003e\u003cp\u003eIf there are several ways to choose the unluckiest number, output any of them.\u003c/p\u003e"}},{"title":"Examples","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\u003e5\n59 63\n42 49\n48 53\n90 90\n1 100\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e63\n44\n53\n90\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eLet\u0027s look at two test examples: \u003c/p\u003e\u003cul\u003e \u003cli\u003e the luckiness of the number $$$59$$$ is $$$9 - 5 \u003d 4$$$; \u003c/li\u003e\u003cli\u003e the luckiness of $$$60$$$ equals $$$6 - 0 \u003d 6$$$; \u003c/li\u003e\u003cli\u003e the luckiness of $$$61$$$ equals $$$6 - 1 \u003d 5$$$; \u003c/li\u003e\u003cli\u003e the luckiness of $$$62$$$ equals $$$6 - 2 \u003d 4$$$; \u003c/li\u003e\u003cli\u003e the luckiness of $$$63$$$ is $$$6 - 3 \u003d 3$$$. \u003c/li\u003e\u003c/ul\u003e So the unluckiest number is $$$63$$$.\u003cp\u003eIn the fifth test case, the unluckiest numbers are $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$7$$$, $$$8$$$, $$$9$$$, $$$11$$$, $$$22$$$, $$$33$$$, $$$44$$$, $$$55$$$, $$$66$$$, $$$77$$$, $$$88$$$, $$$99$$$, so you are allowed to choose any of them.\u003c/p\u003e"}}]}