On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4 directionally adjacent number and swapping it.
Given the puzzle board, print the least number of moves required so that the state of the board is solved. If it is impossible for the state of the board to be solved, print -1.
solved state is : {{1,2,3},{4,5,0}}Input Format
Each of next 2 lines contain 3 integer.
Output Format
Min number of moves required to achieve solved state.
Constraints
rows = 2 cols = 3
Example
Input
1 2 3 4 0 5
Output
1