Stripes is a two player game. Necessary requisites are a board and rectangular stripes in three colours: red, green and blue. All the red stripes have dimensions
, green -
, and blue -
, where
,
and
are integers. Players have at their disposal an unlimited pool of stripes of each colour.
A game board is a rectangle of dimensions
and consists of
fields of size
.
Players make their moves by turns. Move consists of laying a stripe of any colour on the board. There are the following rules in force:
The first player is this one, who makes the first move in the game. It is said, that the first player has a winning strategy, if independently of the moves of the second player he can always win.
Write a program which:
The first line of the standard input consists of three integers
,
and
,
, equal to the lengths of stripes, adequately: red, green and blue ones. Numbers in the line are separated by single spaces.
The second line of the standard input consists of one number
,
, which is equal to the number of different boards to consider. Lines from the 3-rd to the (
)-th consists of one number
,
. Number in the (
)-th line is the length of the
-th board.
The standard output should contain
lines. Only one number should be written in the
-th line of the file:
-th board
For the input data:
1 5 1 3 1 5 6
the correct result is:
1 1 2
Task author: Adam Borowski.
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.