The chessboard state is recorded only if the base case is reached, i.e., all N queens are successfully placed. For any non-viable move, the queen is removed from the current position (backtracking) and other positions are explored (in a recursive manner):