Another Contest 9 Problem 1 - Black Room Boy

View as PDF

Submit solution


Points: 3
Time limit: 1.0s
Memory limit: 256M

Problem type

Nick is inside a rectangular black room. He knows how far away he is from each of the room's four walls. What are the possible dimensions of the room?

Constraints

1 \le T \le 10^4

1 \le d_1, d_2, d_3, d_4 \le 10

Input Specification

The first line contains a single positive integer, T, the number of test cases. T test cases follow.

Each test case consists of a single line that contains four space-separated positive integers, d_1 through d_4. These four integers represent how far Nick is from each of the four walls of the room.

Output Specification

Output the answers for the T test cases in order. There should be no blank lines in your output.

The answer for a test case should take K+1 lines, where K is the number of distinct room dimensions that are attainable. The first line should contain an integer K; then, the next K lines should contain two space-separated integers a_i and b_i, indicating that a rectangular room of dimensions a_i \times b_i is attainable. These lines should be printed in increasing order of a_i, tiebreaking in increasing order of b_i.

Sample Input

2
1 1 1 1
1 2 3 4

Sample Output

1
2 2
5
3 7
4 6
5 5
6 4
7 3

Comments

There are no comments at the moment.