reimplemented n-queen