Polish version    English version  
  History of OI -> VII OI 1999/2000 -> Problems


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Organization
Hints
Schedule
Stats
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
VII Olimpiada Informatyczna 1999/2000

Task: PAS
Author: Adam Borowski
Stripes

I stage contest  

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 c x 1, green - z x 1, and blue - n x 1, where c, z and n are integers. Players have at their disposal an unlimited pool of stripes of each colour.

A game board is a rectangle of dimensions p x 1 and consists of p fields of size 1 x 1.

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:

  • A stripe cannot stick out of the board,
  • The covering (even partially) the earlier laid stripes is forbidden.
  • The ends of a stripe have to adhere to the edges of the fields on the board. The player, who is not able to perform his move in accordance to the game rules first, loses.

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.

Task

Write a program, which:

  • reads sizes of stripes and of at least one board from the text file PAS.IN
  • for each board determines, whether the first player has a winning strategy,
  • writes the results to the text file PAS.OUT.

Input

The first line of the input file PAS.IN consists of three integers c, z and n, 1 <= c, z, n <= 1000, 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 file PAS.IN consists of one number m, 1 <= m <= 1000, which is equal to the number of different boards to consider. Lines from the 3-rd to the (m+2)-th consists of one number p, 1 <= p < 1000. Number in the (i+2)-th line is the length of the i-th board.

Output

The output file PAS.OUT should contain m lines. Only one number should be written in the i-th line of the file:

  • 1 - if the first player has a winning strategy on the i-th board
  • 2 - otherwise.

Example

For the input file PAS.IN:

1 5 1
3 
1 
5 
6

the correct result is the output file PAS.OUT

1
1 
2



Print friendly version