Consider a grid with $$$3$$$ rows and $$$3$$$ columns. Each cell of the grid has an integer in it. Each integer from $$$1$$$ to $$$9$$$ (both inclusive) appears exactly once in the grid.
You can perform the following three types of operations on the grid.
Given two such grids, calculate the minimum number of operations needed to transform the first grid to the second one.
There are multiple test cases. The first line of the input contains an integer $$$T$$$ ($$$1 \le T \le 2 \times 10^5$$$), indicating the number of test cases. For each test case:
For the first three lines, the $$$i$$$-th line contains a string $$$a_{i,1}a_{i,2}a_{i,3}$$$ ($$$1 \le a_{i,j} \le 9$$$), indicating the $$$i$$$-th line of the first grid.
For the following three lines, the $$$i$$$-th line contains a string $$$b_{i,1}b_{i,2}b_{i,3}$$$ ($$$1 \le b_{i,j} \le 9$$$), indicating the $$$i$$$-th line of the second grid.
For each test case output one line. If it is possible to transform the first grid to the second one, output an integer indicating the minimum number of operations needed; If it is impossible to do so, output -1 instead.
4293678514624579183624579183293678514123456789321456789123456789123456789
3 5 -1 0
For the first sample test case, as shown in the description, we can first right-shift the third row, then down-shift the first column, and finally rotate clockwise.
| Name |
|---|


