Turned away from class

Given Hyobin's random arrival time in [D,E] and Yeongseon's fixed wait-walk cycle, compute the probability that Yeongseon is C or more seconds late.

Medium6MathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Hyobin lectures to friends at an algorithm club. The lectures are perfect, but Hyobin does not keep to the clock.

Yeongseon arrives at the classroom right when the lecture is supposed to start, with no idea when Hyobin will show up. To spend less time just sitting and waiting, Yeongseon uses this routine.

  • Yeongseon reaches the classroom at time 0.
  • Yeongseon waits in the classroom for Hyobin.
  • If Hyobin has not arrived after AA seconds, Yeongseon steps outside and takes a walk for BB seconds.
  • Yeongseon gets back to the classroom at time A+BA+B.
  • After returning, Yeongseon waits another AA seconds, and if Hyobin still has not arrived, takes another walk of BB seconds.
  • This repeats until Hyobin comes to the classroom.

So Yeongseon is in the classroom from second 00 to second AA, from second A+BA+B to second 2A+B2A+B, and so on at the same spacing. Each of those intervals includes both endpoints. At every other moment Yeongseon is outside on a walk.

Hyobin does not forgive tardiness. If Hyobin is already in the classroom when Yeongseon comes back from a walk, Yeongseon counts as late. If Yeongseon reaches the classroom CC or more seconds after the moment Hyobin arrived, Yeongseon cannot attend Hyobin's class.

The time at which Hyobin reaches the classroom is distributed uniformly over the real interval from DD to EE seconds, endpoints included. Write a program that computes the probability that Yeongseon cannot attend Hyobin's class.

Input

The first line contains five integers AA, BB, CC, DD, EE separated by spaces. (1A,B,C,E1071 \le A, B, C, E \le 10^7, 0DE0 \le D \le E)

Output

Print the probability that Yeongseon cannot attend Hyobin's class on the first line, as a reduced fraction p/q. Here pp and qq are integers with q1q \ge 1 and gcd(p,q)=1\gcd(p, q) = 1. Print 0/1 when the probability is 00 and 1/1 when it is 11.

If D=ED = E, Hyobin's arrival time is fixed at second DD. In that case print 1/1 when Yeongseon cannot attend, and 0/1 when Yeongseon can.

Explanation

Take A=20A = 20, B=30B = 30, C=10C = 10, D=0D = 0, E=50E = 50. Hyobin arrives at some moment between second 0 and second 50. Yeongseon waits in the classroom from second 0 to second 20, walks from second 20 to second 50, and is back in the classroom at second 50. Hyobin waits only up to 10 seconds after arriving. So if Hyobin arrives between second 20 and second 40, Yeongseon returns at second 50 and cannot attend. That stretch has length 20 and the whole range has length 50, so the probability is 20/50, which as a reduced fraction is 2/5.