Football Team Photo

No attempts yetTime limit5sMemory limit512 MB

Problem

A football team lines up in rows to have a photograph taken. The position of each player is given by two integers xx and yy: yy is the row number and xx is the distance from the left edge of that row to the player. Within one test case all xx 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 PP is this.

  • The nearest player to the right of PP in the same row, if there is one, must have a shirt color different from PP.
  • The nearest player to the right of PP in the previous row, if there is one, must have a shirt color different from PP.
  • The nearest player to the right of PP in the next row, if there is one, must have a shirt color different from PP.

Written formally, if there are players at (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) with x1<x2x_1 < x_2, the two players must have different shirt colors when both of these hold.

  • y11y2y1+1y_1 - 1 \le y_2 \le y_1 + 1
  • There is no x3x_3 with a player at (x3,y2)(x_3, y_2) and x1<x3<x2x_1 < x_3 < x_2.

Find the minimum number of distinct shirt colors that makes such an assignment possible.

Input

The first line contains one integer TT, the number of test cases. Each test case starts with a line containing one integer NN, the number of players, followed by NN lines that each give the position of one player in the form

x y

Limits

  • 1T1001 \le T \le 100
  • 1N1001 \le N \le 100
  • 1x10001 \le x \le 1000
  • 1y151 \le y \le 15
  • Within one test case all xx values are different.

Output

For each test case, print one line in the form

Case #X: c

where XX is the test case number starting from 1 and cc is the minimum number of shirt colors.