modified NQPuzzle.java