{"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\"\u003eEight-puzzle, which is also called \"Nine grids\", comes from an old game. \u003cbr\u003e\u003cbr\u003eIn this game, you are given a 3 by 3 board and 8 tiles. The tiles are numbered from 1 to 8 and each covers a grid. As you see, there is a blank grid which can be represented as an \u0027X\u0027. Tiles in grids having a common edge with the blank grid can be moved into that blank grid. This operation leads to an exchange of \u0027X\u0027 with one tile.\u003cbr\u003e\u003cbr\u003eWe use the symbol \u0027r\u0027 to represent exchanging \u0027X\u0027 with the tile on its right side, and \u0027l\u0027 for the left side, \u0027u\u0027 for the one above it, \u0027d\u0027 for the one below it.\u003cbr\u003e\u003cbr\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/671f4d3b6e4f813711be59c11286128e?v\u003d1714931347\"\u003e\u003cbr\u003e\u003cbr\u003eA state of the board can be represented by a string S using the rule showed below.\u003cbr\u003e\u003cbr\u003e\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/23e43083209c3a766ab92e1429ae5a49?v\u003d1714931347\"\u003e\u003cbr\u003e\u003cbr\u003eThe problem is to operate an operation list of \u0027r\u0027, \u0027u\u0027, \u0027l\u0027, \u0027d\u0027 to turn the state of the board from state A to state B. You are required to find the result which meets the following constrains:\u003cbr\u003e1. It is of minimum length among all possible solutions.\u003cbr\u003e2. It is the lexicographically smallest one of all solutions of minimum length.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line is T (T \u0026lt;\u003d 200), which means the number of test cases of this problem.\u003cbr\u003e\u003cbr\u003eThe input of each test case consists of two lines with state A occupying the first line and state B on the second line.\u003cbr\u003eIt is guaranteed that there is an available solution from state A to B.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case two lines are expected.\u003cbr\u003e\u003cbr\u003eThe first line is in the format of \"Case x: d\", in which x is the case number counted from one, d is the minimum length of operation list you need to turn A to B.\u003cbr\u003eS is the operation list meeting the constraints and it should be showed on the second line.\u003cbr\u003e"}},{"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\u003e2\r\n12X453786\r\n12345678X\r\n564178X23\r\n7568X4123\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 2\r\ndd\r\nCase 2: 8\r\nurrulldr\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}