A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once.
If the knight ends on a square that is one knight's move from the beginning square the tour is closed, otherwise it is open.

Goal

Find a knight's tour on a chess board with n × m squares.

History

The earliest known reference to the knight's tour problem dates back to the 9th century AD.