Football Team Photo
InterviewTime limit5sMemory limit512 MB
Each player must differ in color from the next player to the right within one row of their row; find the minimum number of colors.
Problem
A football team lines up in rows to have a photograph taken. The position of each player is given by two integers and : is the row number and is the distance from the left edge of that row to the player. Within one test case all values are different.
To make the photo more interesting, players who stand near each other get shirts of different colors. The rule for a player is this.
- The nearest player to the right of in the same row, if there is one, must have a shirt color different from .
- The nearest player to the right of in the previous row, if there is one, must have a shirt color different from .
- The nearest player to the right of in the next row, if there is one, must have a shirt color different from .
Written formally, if there are players at and with , the two players must have different shirt colors when both of these hold.
- There is no with a player at and .
Find the minimum number of distinct shirt colors that makes such an assignment possible.
Input
The first line contains one integer , the number of test cases. Each test case starts with a line containing one integer , the number of players, followed by lines that each give the position of one player in the form
x y
Limits
- Within one test case all values are different.
Output
For each test case, print one line in the form
Case #X: c
where is the test case number starting from 1 and is the minimum number of shirt colors.