CF2002A.Distanced Coloring

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Distanced Coloring

You received an n×mn\times m grid from a mysterious source. The source also gave you a magic positive integer constant kk.

The source told you to color the grid with some colors, satisfying the following condition:

  • If (x1,y1)(x_1,y_1), (x2,y2)(x_2,y_2) are two distinct cells with the same color, then max(x1x2,y1y2)k\max(|x_1-x_2|,|y_1-y_2|)\ge k.

You don't like using too many colors. Please find the minimum number of colors needed to color the grid.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001\le t\le1000). The description of the test cases follows.

The only line of each test case consists of three positive integers nn, mm, kk (1n,m,k1041\le n,m,k\le10^4) — the dimensions of the grid and the magic constant.

Output

For each test case, print a single integer — the minimum number of colors needed to color the grid.

Note

In the first test case, one of the optimal constructions is:

In the second test case, the color of all cells must be pairwise different, so the answer is 55.

Samples

6
3 3 2
5 1 10000
7 3 4
3 2 7
8 9 6
2 5 4
4
5
12
6
36
8

在线编程 IDE

建议全屏模式获得最佳体验