Pareto domination#100

Pareto domination

10 seconds
64 megabytes
Hard

A point with coordinates (x_1, x_2, \ldots, x_n) is said to dominate (in the Pareto sense) a point with coordinates (y_1, y_2, \ldots, y_n) if for every (1 \leq i \leq n), the inequality x_i \leq y_i holds.

Given a set of points, determine the number of points that are not dominated in the Pareto sense by any other point in the set.

Input

The first line contains the number of test cases (1 \leq T \leq 10).

Each test case begins with a line containing two integers: (1 \leq N \leq 50000), the number of points in the set, and (1 \leq M \leq 4), the dimension of the space. The following lines each contain integers separated by spaces, representing the coordinates of a point. The absolute value of each coordinate is less than 10^9. All points in each set are distinct.

Output

Print lines. For each test case, output a single line in the format: "Case #A: B", where is the test case number (starting from ), and is the number of non-dominated points for that test case.

Examples

Example 1

Loading
Loading