Problem B
Breaking Cake
The Hunter Exam has begun!
The first round of the Hunter Exam is a real-life problem
solving test: Each candidate is given a rectangular
parallelepiped cake of size
Inside the cake, there are
The candidates must divide their given cake into exactly
-
For every two parts, their common space’s volume must be zero.
-
Each part must contain exactly one chocolate chip.
-
The coordinates of the corners of all
parts must be integers. -
To prevent wasted food, candidates cannot throw away any part of the cake.
Can you divide the cake satisfying all the constraints and pass the first round of the Hunter Exam?
Input
The input contains multiple test cases. Each test case is described as below:
-
The first line contains exactly
positive integers , , and . . -
In the next
lines, the -th line contains exactly positive integers , and — the coordinates of the -th chocolate chip. No two chips are in the same position. .
Sum of
The last line of the input contains a single number
Output
For each test case:
-
If it is impossible to divide the cake satisfying the above constraints, print exactly one line containing ‘NO’ .
-
Otherwise, output one line containing ‘YES’, followed by
lines. The -th line contains exactly integers, , , , , and representing the -th part . and are the coordinates of two opposite unit cubes of the -th part. The -th part must contain the -th chocolate chip.
Sample Input 1 | Sample Output 1 |
---|---|
5 5 5 2 1 1 1 5 5 5 5 5 5 1 3 3 3 -1 |
YES 1 1 1 5 5 1 1 1 2 5 5 5 YES 1 1 1 5 5 5 |