{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ch1\u003eMove On Dice\u003c/h1\u003e\n\n\u003cp\u003eThere is a cube on a rectangle map with \u003cvar\u003eH\u003c/var\u003e-rows and \u003cvar\u003eW\u003c/var\u003e-columns grid.\nTwo special squares a start and a goal are marked on the map.\nInitially, the cube is on the start square. Let\u0027s repeat to roll it and take it to the goal square.\nRolling the cube means to select one of four edges which touch the map, and push the cube down without detaching the edge from the map.\nThat is, there are four directions you can move the cube toward.\n\u003c/p\u003e\n\u003cp\u003eDirections where we can roll the cube are limited depending on each square.\nAn instruction is written in each square and represented by a single character as follows:\n\u003c/p\u003e\u003cdl\u003e\n \u003cdt\u003e\u0027+\u0027\u003c/dt\u003e\u003cdd\u003eall\u003c/dd\u003e\n \u003cdt\u003e\u0027|\u0027\u003c/dt\u003e\u003cdd\u003eonly vertical\u003c/dd\u003e\n \u003cdt\u003e\u0027-\u0027\u003c/dt\u003e\u003cdd\u003eonly horizontal\u003c/dd\u003e\n \u003cdt\u003e\u0027\u0026lt;\u0027\u003c/dt\u003e\u003cdd\u003eonly to left\u003c/dd\u003e\n \u003cdt\u003e\u0027\u0026gt;\u0027\u003c/dt\u003e\u003cdd\u003eonly to right\u003c/dd\u003e\n \u003cdt\u003e\u0027^\u0027\u003c/dt\u003e\u003cdd\u003eonly to up\u003c/dd\u003e\n \u003cdt\u003e\u0027v\u0027 \u003c/dt\u003e\u003cdd\u003eonly to down\u003c/dd\u003e\n \u003cdt\u003e\u0027.\u0027\u003c/dt\u003e\u003cdd\u003enone\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003cp\u003eRegardless of instructions, it is not allowed to roll the cube to outside of the map.\n\n\n\u003c/p\u003e\n\u003cp\u003eOn each face of the cube, a string is written.\nLet\u0027s output the string which concatenates strings written on the top face seen during the rollings from the start square to the goal square. \nSince there may be multiple paths that take the cube to the goal square, choose the minimal string in ascending lexicographic order.\n\u003c/p\u003e\n\u003cp\u003ePlease note that there are cases where no path exists from the start to the goal, or the cases you can make the lexicographically minimal string infinitely longer.\n\u003c/p\u003e\n\n\u003ch2\u003eInput\u003c/h2\u003e\n\u003cp\u003eA data set has following format:\n\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cvar\u003eH\u003c/var\u003e \u003cvar\u003eW\u003c/var\u003e\u003cbr\u003e\n \u003cvar\u003eC\u003csub\u003e11\u003c/sub\u003e\u003c/var\u003e ... \u003cvar\u003eC\u003csub\u003e1W\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n ...\u003cbr\u003e\n \u003cvar\u003eC\u003csub\u003eH1\u003c/sub\u003e\u003c/var\u003e ... \u003cvar\u003eC\u003csub\u003eHW\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n \u003cvar\u003eT\u003csub\u003e1\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n ...\u003cbr\u003e\n \u003cvar\u003eT\u003csub\u003e6\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n \u003cvar\u003eR\u003csub\u003eS\u003c/sub\u003e\u003c/var\u003e \u003cvar\u003eC\u003csub\u003eS\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n \u003cvar\u003eR\u003csub\u003eD\u003c/sub\u003e\u003c/var\u003e \u003cvar\u003eC\u003csub\u003eD\u003c/sub\u003e\u003c/var\u003e\u003cbr\u003e\n\u003c/blockquote\u003e\n\n\u003cp\u003eThe first line of the input contains two integers \u003cvar\u003eH\u003c/var\u003e (\u003cvar\u003e1 ≤ H ≤ 12\u003c/var\u003e) and \u003cvar\u003eW\u003c/var\u003e (\u003cvar\u003e1 ≤ W ≤ 12\u003c/var\u003e), which indicate the number of rows and columns of the map respectively.\nThe following \u003cvar\u003eW\u003c/var\u003e lines describe the map.\nThe \u003cvar\u003ej\u003c/var\u003e-th character of the \u003cvar\u003ei\u003c/var\u003e-th line indicates the instruction of the square, which is placed on \u003cvar\u003ei\u003c/var\u003e-th row (from the top) and \u003cvar\u003ej\u003c/var\u003e-th column (from the left).\n\u003c/p\u003e\n\u003cp\u003eThen the following 6 lines describe the strings on each face of the cube.\nAll of these strings are not empty and shorter than 12 characters (inclusive).\nIn addition, they only consist of uppercase alphabets or digits.\nThe faces where the strings are written are given as figure 1.\nInitially, the cube is placed on the start square in a direction as the face No. 1 is facing top and the upper direction of face No. 1 faces toward the top row of the map.\n\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/12926b20504f9892e3f3237393c2804c?v\u003d1715981828\" height\u003d\"183\" width\u003d\"341\"\u003e\u003c/center\u003e\n\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\u003ccenter\u003eFigure 1. a net of a cube\u003c/center\u003e\n\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003eThe last two lines contain two integers each that indicate the row number and column number of the start square and the goal square in this order.\nYou can assume that the start square and the goal square are always different.\n\u003c/p\u003e\n\n\n\u003ch2\u003eOutput\u003c/h2\u003e\n\n\u003cp\u003ePrint the lexicographically minimal string in a line.\nIf there is no path, print \"no\" in a line.\nIf you can make the lexicographically minimal string infinitely longer, print \"infinite\" in a line.\n\u003c/p\u003e\n\n\u003ch2\u003eSample Input 1\u003c/h2\u003e\n\n\u003cpre\u003e1 3\n+++\n6\n5\n4\n3\n2\n1\n1 3\n1 1\n\u003c/pre\u003e\n\n\u003ch2\u003eOutput for the Sample Input 1\u003c/h2\u003e\n\n\u003cpre\u003e621\n\u003c/pre\u003e\n\n\u003ch2\u003eSample Input 2\u003c/h2\u003e\n\n\u003cpre\u003e1 3\n+++\n1\n2\n3\n4\n5\n6\n1 3\n1 1\n\u003c/pre\u003e\n\n\u003ch2\u003eOutput for the Sample Input 2\u003c/h2\u003e\n\n\u003cpre\u003einfinite\n\u003c/pre\u003e\n\n\u003ch2\u003eSample Input 3\u003c/h2\u003e\n\n\u003cpre\u003e1 3\n...\n1\n2\n3\n4\n5\n6\n1 3\n1 1\n\u003c/pre\u003e\n\n\u003ch2\u003eOutput for the Sample Input 3\u003c/h2\u003e\n\n\u003cpre\u003eno\n\u003c/pre\u003e\n\n\u003ch2\u003eSample Input 4\u003c/h2\u003e\n\n\u003cpre\u003e3 3\n-\u0026gt;|\n..v\n.^\u0026lt;\nJAG\n2012\nSUMMER\nHOGE\nHOGE\nCAMP\n1 1\n2 2\n\u003c/pre\u003e\n\n\u003ch2\u003eOutput for the Sample Input 4\u003c/h2\u003e\n\n\u003cpre\u003eJAGSUMMERCAMP2012JAGSUMMER2012\n\u003c/pre\u003e\n"}}]}