Red Ginseng Game (Hard)

Given a cycle of N people and two pointer distances, decide the minimum number of pointings before the two pointers collide, or report that they never meet.

Medium7MathNumber theoryGraphShortest pathNo 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 around a table in a circle and play it by these rules.

  1. Eunha points at two different people.
  2. The two people who were pointed at each choose one person at the table at the same time and point at that person.
  3. If the two chose the same person, the game ends. Otherwise, go back to rule 2.

After the contest the contestants went to a nearby bar for an after party, and Eunha led them into a red ginseng game. So many people had gathered that nobody could see who was pointing at whom, and the game stopped again and again. Eunha's friend Eunseo could not watch this any longer and proposed the "orderly red ginseng game", which changes the rules like this.

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

Thanks to Eunseo's proposal the contestants could enjoy the game in an orderly way. Eunha then kept the game running for hours, so the exhausted contestants decided to finish the game as quickly as possible no matter whom Eunha points at and no matter how she sets the two pointing distances. Rescue them from red ginseng hell.

For convenience, assume the participants are numbered 1 to NN counterclockwise. That is, participant i1i - 1 sits immediately to the left of participant ii, and participant i+1i + 1 sits immediately to the right. As the exception, participant NN sits immediately to the left of participant 1, and participant 1 sits immediately to the right of participant NN.

Input

The first line contains the number of participants of the orderly red ginseng game NN (2N5000002 \le N \le 500000), the number AA of the person Eunha pointed at first and the number BB of the person she pointed at second (1A,BN1 \le A, B \le N, ABA \ne B), and the integers DAD_A and DBD_B that give the pointing distance of each pointer (1DA,DBN11 \le D_A, D_B \le N - 1), separated by spaces and given in that order.

Output

On the first line, print the smallest number of pointings needed to finish the given game as quickly as possible. If the game cannot be finished, print Evil Galazy. The two people Eunha points at in rule 1 do not count toward the number of pointings.

Hint

When N=6N = 6, A=5A = 5, B=1B = 1, DA=1D_A = 1 and DB=2D_B = 2, the following order finishes the game in three pointings.

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