IOI '05 - Nowy Sacz, Poland
Three children are building the Polish flag from square blocks. The flag
will be a rectangle, blocks wide and
blocks high, where
is
a positive integer. It will consist of
white blocks and
red blocks. The children are going to lay blocks on a
rectangle table. There are
slots on the table. The
white blocks should occupy the top
rows, and the red blocks should
occupy the bottom
rows. Rows are numbered from
to
from top to
bottom. Columns are numbered from
to
from left to right.
The children are laying blocks in turns. In the first turn, Lucy puts her
block on the left edge at position , Bob puts his block on the
bottom edge at position
, Roy puts his block on the right edge
at position
, where
.
Every next turn they lay blocks as follows. The child can put a block in a given slot only if the slot is empty and the block to be put would be adjacent to one of the blocks put in the preceding turn. (Two blocks are adjacent if they have a common side.) In a given turn the child puts as many blocks as possible. Only one block can be put into a single slot. If two or more children want to put a block into the same slot in the same turn then the highest priority has Lucy, then Bob and the lowest priority has Roy.
Before the children start building the flag they have to distribute blocks. Here is the problem. They don't know how many blocks of each color they need. Help the children and compute for each child the number of blocks of each color he/she will use while building the flag.
Input Specification
The first and only line contains four integers ,
,
,
,
separated by single spaces,
.
Additionally, in
of test cases
will not exceed
.
Output Specification
Output should consist of a single line containing six integers separated by single spaces. The first and the second integer should be the number of white and red blocks respectively, which Lucy needs; the third and fourth number should be the number of white and red blocks respectively, which Bob needs; the fifth and sixth number should be the number of white and red blocks respectively, which Roy needs.
Sample Input
2 2 3 1
Sample Output
7 3 0 8 5 1
Comments