Competitive Programming in Haskell: Scanner by Brent Yorgey

There is another common class of problems, however, which follow this pattern: “The first line of the input consists of an integer T . Each of the next T lines consists of …” That is, the input contains integers which are not input data per se but just tell you how many things are to follow.