correctly prints valid solutions