the mythic world Chess Land rectangular grid square r row c column r great equal c its row column number 1 r 1 c respectively the inhabitant Chess Land usually mention piece everyday language 5 specific type roam land pawn rooks bishop queen king contrary popular belief chivalry long dead Chess Land knight foundEach piece unique way move square square step pawn row forward ie row r r1 change column rook number column leftright change row or number row forwardbackward change column bishop square diagonal intersect currently occupy square queen square rook bishop position king 8 adjacent square in follow figure mark X square piece single step row number column leave right recently Chess Land dangerous place piece pass land capture unexpectedly unknown force simply disappear as consequence like reach destination fast ie move possible interested number different way possible reach minimal number step path available mean low chance getting capture two path consider different differ visit squarefor problem let assume piece enter Chess Land give column row 1 exit land give column row r your task answer Q question give type piece column enter row 1 column reach row r order exit compute minimal number move Chess Land number different way able