logo AlgoBeat OnlineJudge
登录 注册

#206196. [NWRRC 2016] Hard Cuts

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

输入格式

The first line contains a single integer -- the number of test cases . Each of the lines contains two integers -- the dimensions of the rectangle ; for any or

输出格式

For the i-th test case, output -- the minimal number of squares, such that it is possible to cut by rectangle into squares. The following should contain three integers each: coordinates of the bottom-left corner of the j-th square and its side length The bottom-left corner of the rectangle has coordinates and the top-right coordinates

样例

样例输入 1

3
5 3
5 6
4 4

样例输出 1

4
0 0 3
3 0 2
3 2 1
4 2 1
5
0 0 2
0 2 2
0 4 2
2 0 3
2 3 3
1
0 0 4

数据范围与提示

Time limit: 2 s, Memory limit: 256 MB.