{"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\"\u003e现在有一个紧急任务需要你打开一个密码锁。密码由四位数字组成。每个数字从1到9编号。\u003cbr\u003e每次,你可以给任意数字加1或减1。当对\u00279\u0027加1时,数字将变为\u00271\u0027,当对\u00271\u0027减1时,数字将变为\u00279\u0027。你还可以与相邻的数字交换位置。每个动作都将消耗一步。\u003cbr\u003e\u003cbr\u003e现在你的任务是用最少的步骤打开锁。\u003cbr\u003e\u003cbr\u003e注意:最左边的数字不是最右边数字的相邻数字。\u003cbr\u003e\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"输入文件以一个整数T开头,表示测试用例的数量。\u003cbr\u003e\u003cbr\u003e每个测试用例以四位数字N开头,表示密码锁的初始状态。然后是另一行四位数字M,表示可以打开锁的密码。每个测试用例之间有一个空行。\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例,在一行中打印出最小步数。\u003cbr\u003e"}},{"title":"示例","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\n1234\r\n2144\r\n\r\n1111\r\n9999\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n4\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}