For each test case, print the minimum waiting time in sum, or "INF" if it is impossible to pick up all the passengers, in a single line.
To make the problem more concise, we assume that passengers will line up in the order of arrival to get on the train. And for every piece of entering record (t, N), the N passengers will either get on the train or wait together. The train is always empty when entering the station. You may not use all of the trains, But only the last train to be used can arrive later than t(M).