{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n A magic square is a $3 \\times 3$ square, where each element is a single digit between 1 and 9 inclusive, and each digit appears exactly once. There are 4 different contiguous $2 \\times 2$ subsquares in a magic squares, which are labeled from 1 to 4 as the following figure shows. These $2 \\times 2$ subsquares can be rotated. We use the label of the subsquare with an uppercase letter to represent a rotation. If we rotate the subsquare clockwise, the letter is \u0027C\u0027; if we rotate it counterclockwise, the letter is \u0027R\u0027. The following figure shows two different rotations.\u003cbr\u003e\u003cbr\u003e\n \u003ccenter\u003e\n \u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/df5368137e47ebc4c00873226b13ac67?v\u003d1679636595\"\u003e\n \u003c/center\u003e\u003cbr\u003e\u003cbr\u003e\n Now, given the initial state of a magic square and a sequence of rotations, please print the final state of the magic square after these rotations are performed.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input is a single integer $T$ $(1 \\leq T \\leq 100)$, the number of test cases.\u003cbr\u003e\u003cbr\u003e\nEach test case begins with a single integer $n$ $(1 \\leq n \\leq 100)$, the number of rotations. It is then followed by a $3 \\times 3$ square, where every digit between 1 and 9 inclusive appears exactly once, representing the initial state of the magic square. The following $n$ lines describe the sequence of rotations.\u003cbr\u003e\u003cbr\u003e\nThe test data guarantees that the input is valid."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, display a $3 \\times 3$ square, denoting the final state of the magic square."}},{"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\u003e\u003cpre\u003e1\r\n2\r\n123\r\n456\r\n789\r\n1C\r\n4R\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e413\r\n569\r\n728\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}