Problem
You need to hire some people to paint a fence. The fence is composed of 10000 contiguous sections, numbered from 1 to 10000.
You get some offers from painters to help paint the fence. Each painter offers to paint a contiguous subset of fence sections in a particular color. You need to accept a set of the offers, such that:
If it is possible to satisfy these two requirements, find the minimum number of offers that you must accept.
Input
Output
Limits
1 ≤ T ≤ 50Small dataset
1 ≤ N ≤ 10
Large dataset
1 ≤ N ≤ 300
Sample
Input 
Output 
5

Case #1: 2

In the first test case, accepting both offers will exactly paint the whole fence, 5000 sections each, with no overlap.
In the second case, the painters will overlap, which is acceptable.
In the third case, accepting all four offers would cover the whole fence, but it would use 4 different colours, so this is not acceptable.
In the fourth case, section 4001 cannot be painted.
In the fifth case, we can accept just the first and second offer and successfully paint the fence.
Points  Correct  Attempted 

7pt  190  199 
13pt  113  144 