URI Online Judge | 3005

Stacks of Parallelepipeds

By Paulo E. D. Pinto, Universidade do Estado do Rio de Janeiro BR Brazil

Timelimit: 3

A gardener has a lot of parallelepiped-shaped pieces of granite and wants to form a stacked sculpture of these two blocks. It can rotate conveniently the blocks, but can only stack two blocks if the face of the block that will remain below have dimensions larger than the face to be stacked. Make a program to help him with this task.


The input consists of a series of tests. The first line contains a single integer indicating the number n (1 ≤ n ≤ 20) of test cases. Following there are n lines each containing a test case. Each test case is composed by 6 integers in one line. The first three integers are the dimensions of the first block and the last three, the dimensions of the other.


For each test case print an integer from 0 to 3 on one line with the following meaning:

   0, if no block can be stacked on top of another.

   1, if only the first block can be stacked on top of the second.

   2, if only the second block can be stacked on top of the first.

   3, If each block can be conveniently stacked on the other.

Input Sample Output Sample


10 10 10 10 20 10

12 20 14 30 10 10

8 20 14 20 10 10