Solution to NQueen Problem