Олимпиадный тренинг

Задача 38628. Two horses


Задача

Темы: Обход в ширину
On a standard chessboard (8x8) there are 2 chess knights: Red and Green. Usually they carelessly jump across the expanses of the board, pinching the chess grass, but today is a special day: the Green Horse has a birthday. The green horse decided to celebrate this event with the red one. But for the implementation of this wonderful plan, they need to be on the same cell. Note that the Red and Green chess knights are very different from black and white: they do not move in turn, but at the same time, and if they end up on the same square, no one eats anyone. How many moves will they need to enjoy the holiday?

Input
The input of the program is the coordinates of the horses, written according to standard chess rules (i.e., two characters - a small Latin letter (from a to h) and a number (from 1 to 8), defining a column and a row, respectively).

Imprint
It is required to output the least required number of moves, or the number -1 if the knights cannot meet.
Examples
# Input Output
1 a1 a3 1