Red Ginseng Game (Easy)

Two tokens move around a cycle, each jumping exactly D seats left or right per turn; find the fewest moves until a token lands on the other token's holder.

Medium5BFSGraphMathImplementationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

Eunha likes drinks, games, and drinking games. Her favorite drinking game is the red ginseng game. NN people sit in a circle around a table and play it by these rules.

  1. Eunha points at two different people.
  2. The two people who were pointed at simultaneously pick one person each from everyone at the table and point at them.
  3. If the two picked the same person, the game ends. Otherwise, go back to rule 2.

After the contest the participants went to a nearby bar for the after party, and Eunha got everyone to play the red ginseng game. So many people had gathered that nobody could tell who was pointing at whom, so the game kept stopping. Eunseo, a friend of Eunha, could not watch this any longer and proposed the orderly red ginseng game, which changes the rules.

  1. Eunha points at two different people, one after the other. The person pointed at first receives pointing token A, and the person pointed at second receives pointing token B.
  2. The person holding pointing token A points at the one person sitting exactly DAD_A seats to their left or exactly DAD_A seats to their right, and hands that person the token.
  3. If that person already holds pointing token B, the game ends.
  4. The person holding pointing token B points at the one person sitting exactly DBD_B seats to their left or exactly DBD_B seats to their right, and hands that person the token.
  5. If that person already holds pointing token A, the game ends. Otherwise, go back to rule 2.

Thanks to Eunseo the participants could play the red ginseng game in an orderly way. Eunha kept running the game for hours, the participants wore out, and they started trying to end each game as fast as possible no matter whom Eunha points at and whatever pointing distances she sets. Rescue the after party from red ginseng hell.

The participants are numbered 1 to NN counterclockwise. Participant ii has participant i1i - 1 immediately to the left and participant i+1i + 1 immediately to the right. As the exception, participant 1 has participant NN immediately to the left, and participant NN has participant 1 immediately to the right.

Input

The first line contains the number of participants NN (2N5002 \le N \le 500), the number AA of the person Eunha points at first and the number BB of the person she points at second (1A,BN1 \le A, B \le N, ABA \ne B), and the integers DAD_A and DBD_B giving the pointing distance of each token (1DA,DBN11 \le D_A, D_B \le N - 1), separated by spaces in that order.

Output

Print, on the first line, the minimum number of pointings needed to end the given game as fast as possible. The opening move in which Eunha points at the two people does not count. If the game can never end, print Evil Galazy.

Hint

The game with N=6N = 6, A=5A = 5, B=1B = 1, DA=1D_A = 1, DB=2D_B = 2 ends in three pointings if it runs in this order.

  1. Participant 5, who holds pointing token A, can point at participant 4 or participant 6. Point at participant 4 and hand over the token.
  2. Participant 1, who holds pointing token B, can point at participant 5 or participant 3. Point at participant 3 and hand over the token.
  3. Participant 4, who holds pointing token A, points at participant 3, hands over the token, and the game ends.