Hard Cuts#9440

Hard Cuts

1 second
128 megabytes
Medium

Given a rectangle with integer side lengths, your task is to cut it into the smallest possible number of squares with integer side lengths.

Input

The first line contains a single integer (1 \leq t \leq 3600) - the number of test cases. Each of the next lines contains two integers w_i, h_i - the dimensions of the rectangle (1 \leq w_i, h_i \leq 60, for any i \neq j, either w_i \neq w_j or h_i \neq h_j).

Output

For the -th test case, output k_i - the minimal number of squares into which it is possible to cut the w_i by h_i rectangle. The following k_i lines should contain three integers each: x_{ij}, y_{ij} - the coordinates of the bottom-left corner of the -th square and l_{ij} - its side length (0 \leq x_{ij} \leq w_i - l_{ij}, 0 \leq y_{ij} \leq h_i - l_{ij}). The bottom-left corner of the rectangle has coordinates and the top-right corner has coordinates (w_i, h_i).

prb9440.gif

Examples

Example 1

Loading
Loading