1617 solution.
use stdio for 1196 solution