Hide

Problem D
Diagonal Dominos

Alice is playing with triangular grids. She starts with a large equilateral triangle of side length $n$. Each side is divided into $n$ segments of length $1$, and lines are drawn through the division points parallel to the sides, partitioning the large triangle into unit equilateral triangles.

She then removes the top part of the triangle: an equilateral triangle of side length $m$ ($0 \le m < n$) sharing the same orientation and top vertex. The remaining region is an isosceles trapezoid formed by unit equilateral triangles, whose parallel sides have lengths $n$ and $m$.

Alice has an unlimited supply of diagonal dominos. Each domino is a rhombus of side length $1$ with angles $60^\circ $ and $120^\circ $, and it covers exactly two adjacent unit equilateral triangles sharing a common side. Dominos must lie entirely inside the trapezoid and must not overlap.

Determine the maximum number of dominos that can be placed inside the trapezoid. Output such a construction.

Input

First line is $T$ $(1 \le T \le 100)$, number of test cases. A line contains two integers $m$ and $n$ $(0 \le m < n \le 2000)$, sum of $n$ does not exceed 2000.

Output

For each test case, firstly, output a single integer C, the maximum number of diagonal dominos that can be placed inside the trapezoid. For the next C lines, output 4 interger a, b, c, d, if $b^{th}$ unit triangle at $a^{th}$ row and $d^{th}$ unit triangle at $c^{th}$ row are tilled into a domino. The order of the row is considered on the big equilateral triangle of size $n$, so make sure that $a, c > m$.

Sample Input 1 Sample Output 1
1
0 2
1
2 1 2 2

Please log in to submit a solution to this problem

Log in