Mr Chanek win national chess tournament get huge chessboard size n time M Bored play conventional chess Mr Chanek define function FX Y denote minimum number move knight square 1 1 square x Y it turn find FX Y simple Mr Chanek definesGX Y sum_ixn sum_jYM Fi jGiven X Y task find GX YA knight square b square b 0 b b 0 b b 3 of course knight leave chessboard