got the correct answer on sample input