Final Solution, with sample input