Backtracking algorithm for the eight queens problem