{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"真的是洗牌,你可以想象一下开始是由一堆排分成两堆牌,假如一开始就是要求的,就直接输出0,后面通过洗牌操作,计算洗多少次牌才能得到结果,假如得不到结果输出-1!看了我好久的题目,自闭了\n"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n \u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe first line of input contains a single integer \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e, (1 ≤ \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e ≤ 1000) which is the number of datasets that follow.\u003c/p\u003e\u003cp\u003eEach dataset consists of four lines of input. The first line of a dataset specifies an integer \u003ci\u003e\u003cb\u003eC\u003c/b\u003e\u003c/i\u003e, (1 ≤ \u003ci\u003e\u003cb\u003eC\u003c/b\u003e\u003c/i\u003e ≤ 100) which is the number of chips in each initial stack (\u003cb\u003eS\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e and \u003cb\u003eS\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e). The second line of each dataset specifies the colors of each of the \u003ci\u003e\u003cb\u003eC\u003c/b\u003e\u003c/i\u003e chips in stack \u003cb\u003eS\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e, starting with the bottommost chip. The third line of each dataset specifies the colors of each of the \u003ci\u003e\u003cb\u003eC\u003c/b\u003e\u003c/i\u003e chips in stack \u003cb\u003eS\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e starting with the bottommost chip. Colors are expressed as a single uppercase letter (\u003cb\u003eA\u003c/b\u003e through \u003cb\u003eH\u003c/b\u003e). There are no blanks or separators between the chip colors. The fourth line of each dataset contains 2 * \u003ci\u003e\u003cb\u003eC\u003c/b\u003e\u003c/i\u003e uppercase letters (\u003cb\u003eA\u003c/b\u003e through \u003cb\u003eH\u003c/b\u003e), representing the colors of the desired result of the shuffling of \u003cb\u003eS\u003csub\u003e1\u003c/sub\u003e\u003c/b\u003e and \u003cb\u003eS\u003csub\u003e2\u003c/sub\u003e\u003c/b\u003e zero or more times. The bottommost chip’s color is specified first.\u003c/p\u003e\u003c/span\u003e\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n \u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eOutput for each dataset consists of a single line that displays the dataset number (1 though \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e), a space, and an integer value which is the minimum number of shuffle operations required to get the desired resultant stack. If the desired result can not be reached using the input for the dataset, display the value negative 1 (\u003cb\u003e−1\u003c/b\u003e) for the number of shuffle operations.\u003c/p\u003e\u003c/span\u003e\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2\n4\nAHAH\nHAHA\nHHAAAAHH\n3\nCDE\nCDE\nEEDDCC\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e1 2\n2 -1\u003c/pre\u003e"}}]}