Triangle Areas (Large)

Given N, M and A, print the canonical triangle (0,0), (N,1), (w,h) with area A/2, or IMPOSSIBLE when A exceeds N*M.

Easy3GeometryMathImplementationBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

Tangor is ten years old and has just learned how to compute the area of a triangle. He also worked out on his own that if all three vertices of a triangle have integer coordinates, the area is always an integer or half of an integer.

Today he is going the other way. Instead of measuring a triangle he already has, he picks an integer AA and tries to draw a triangle whose area is exactly A/2A/2. The vertices may sit only on the grid points of his graph paper.

The paper is divided into an NN by MM grid of square cells, and the only points he may use as vertices are the corners of those cells. Placing a coordinate system on the paper, a usable point is (x,y)(x, y) for integers xx and yy with 0xN0 \le x \le N and 0yM0 \le y \le M.

Given NN, MM and AA, find three grid points that form a triangle of area exactly A/2A/2, or report that no such triangle fits on the paper.

Input

The first line holds an integer CC, the number of test cases.

Each of the next CC lines holds three integers NN, MM and AA.

Constraints

  • 0C10000 \le C \le 1000
  • 1A1081 \le A \le 10^8
  • 1N100001 \le N \le 10000
  • 1M100001 \le M \le 10000

Output

Print one line for each test case.

Many different triangles can have the same area, so the answer is fixed to a single canonical triangle. Let kk be the case number, counted from 1.

If A>N×MA > N \times M, no triangle of area A/2A/2 fits on the paper. In that case print

Case #k: IMPOSSIBLE

Otherwise let h=A/Nh = \lceil A / N \rceil and w=NhAw = N h - A. These satisfy 1hM1 \le h \le M and 0w<N0 \le w < N, and the triangle with vertices (0,0)(0, 0), (N,1)(N, 1) and (w,h)(w, h) has area exactly A/2A/2. Print those vertices in that order:

Case #k: 0 0 N 1 w h

That is, print the six integers 00, 00, NN, 11, ww, hh separated by single spaces.