Exit from the labyrinth
During a tornado in the Kostroma region, many trees were knocked down. A few days later, a boy named Ilya went for a walk and discovered that the fallen trees had created a labyrinth. Excited, Ilya began to explore and play within it. Suddenly, his teacher called, wondering why Ilya had been absent for so long. To avoid getting in trouble for leaving the camp area without permission, Ilya wanted to return home quickly, but he also wanted to enjoy wandering through the labyrinth.
Help him determine the fastest way to reach his house.
Input
The first line of the input contains two positive integers, N and M (1 ≤ N, M ≤ 1000). The following N lines each contain M characters, representing the labyrinth. Movable positions are marked with "0", while positions blocked by trees are marked with "1". After the labyrinth description, four integers are provided: x_1, y_1, x_2, y_2—these are the coordinates (column and row numbers) of Ilya's starting position and his house (1 ≤ x_1, x_2 ≤ M, 1 ≤ y_1, y_2 ≤ N).
Output
Output a single number: the length of the shortest path from (x_1, y_1) to (x_2, y_2). If Ilya cannot reach the house, output "-1".