A market survey was ordered and Jim has just received an estimated list of passengers’ travel sections. based on the list, he’d like to estimate the minimum number of train seats that meets the demand.
Providing as many seats as all of the passengers may cost unreasonably high. Assigning the same seat to more than one passenger without overlapping travel sections may lead to a great cost cutback.
Two different policies are considered on seat assignments. As the views from the train windows depend on the seat positions, it would be better if passengers can choose a seat. One possible policy (named ‘policy-1’) is to allow the passengers to choose an arbitrary seat among all the remaining seats when they make their reservations. As the order of reservations is unknown, all the possible orders must be considered on counting the required number of seats.
The other policy (named ‘policy-2’) does not allow the passengers to choose their seats; the seat assignments are decided by the railroad operator, not by the passengers, after all the reservations are completed. This policy may reduce the number of the required seats considerably.
Your task is to let Jim know how different these two policies are by providing him a program that computes the numbers of seats required under the two seat reservation policies.
Let us consider a case where there are four stations, S1, S2, S3, and S4, and four expected passengers p1, p2, p3, and p4 with the travel list below.

Let’s check if two seats would suffice under the policy-1. If p1 books a seat first, either of the two seats can be chosen. If p2 books second, as the travel section does not overlap that of p1,the same seat can be booked, but the other seat may look more attractive to p2. If p2 reserves a seat different from that of p1, there will remain no available seats for p3 between S1 and S3
(figure I.1).


On the other hand, deciding the seat assignments after all the reservations are completed enables a tight assignment with only two seats under the policy-2 (figure I.3).
