9119: Puzzle: Square Jam

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:3 通过:0

题目描述

Grammy is a puzzle master. Today, she is playing a variant of "Square Jam" puzzle. Given an n×mn \times mn×m rectangle. The goal is to divide the rectangle into several squares (with integral lengths) such that no point is touched by 4 squares.



The left picture illustrates a solution to a 4×64\times 64×6 puzzle, and the right picture shows an example of what is not allowed in the solution.

Grammy surely knows how to solve the puzzle, but she decided to give you a quiz. Please solve the puzzle.

输入格式

There are multiple test cases.
The first line contains the number of test cases TTT (1≤T≤2×1051 \leq T \leq 2\times 10^51T2×105).
Each of the following TTT lines contains two positive integers n,mn,mn,m (1≤n,m≤1051 \leq n,m \leq 10^51n,m105), denoting the side lengths of the rectangle.
It is guaranteed that the sum of nmnmnm is less than or equal to 2×1052\times 10^52×105.

输出格式

For each test case:
If the solution does not exist, output "NO\texttt{NO}NO" on a single line.
Otherwise, output "YES\texttt{YES}YES" on the first line, then output an integer kkk on the second line, denoting the number of squares divided. Finally, output kkk lines, each of which contains 333 integers x,y,lx,y,lx,y,l, denoting a square of size lll having (x,y)(x,y)(x,y) as its upper-left corner.
For the details of the coordinates, please refer to the following picture. 

输入样例 复制

2
4 6
1 1

输出样例 复制

YES
10
0 0 2
0 2 1
1 2 1
0 3 3
2 0 1
3 0 1
2 1 2
3 3 1
3 4 1
3 5 1
YES
1
0 0 1

分类标签