#Q31. 「一本通 1.4 练习 1」棋盘游戏

「一本通 1.4 练习 1」棋盘游戏

Description

On a 4×44\times 4 chessboard, there are 88 black pieces and 88 white pieces. Two pieces are considered adjacent if and only if their respective squares share a common edge. The rule for moving a piece is to swap two adjacent pieces.
Given an initial chessboard and a target chessboard, find the shortest sequence of moves that transforms the initial chessboard into the target chessboard.

Input Format

The first four lines, each containing 44 numbers (either 11 or 00), describe the initial chessboard;
This is followed by a blank line;
The sixth to ninth lines, each containing 44 numbers (either 11 or 00), describe the target chessboard.

Output Format

The first line of the output file should be an integer nn, representing the minimum number of moves required.

Sample 1

1111
0000
1110
0010

1010
0101
1010
0101

4