Added Pallav's code for printing solution.