Two gamblers after the closure of casinos in the city have decided to bring the gambling excitement to chess, and slightly changed their rules: at first the player throws a hexagonal dice, which determines what piece he will go. And then he throws icosahedra to determine a number of moves in a row that the player must do with this piece before enemies turn.
Task. Determine minimum number of moves needed by the knight standing on cell N to send check to the king standing on cell M if cells T1, T2, …, Tn are set by friendly pieces therefore knight cannot stand there.
Streams. Input stream contains one positive integer n and names of the cells T1, T2, …, Tn, N and M in chess notation. Output stream should contain one positive integer or -1 if there is no chance to send check to the king.
ExampleInput stream:3 A2 D3 F3 E1 D7Output stream:4