A boy named Serhii really wants to learn how to juggle and perform tricks. Recently, his friend showed him a trick: he asked Serhii to imagine a certain positive fraction, then named its denominator and two fractions p_1 / q_1 and p_2 / q_2 such that p_1 / q_1 < a / b < p_2 / q_2, and there is no smaller fraction between them with the same denominator as Serhii's imagined fraction. After that, his friend guessed the numerator of the fraction Serhii was thinking of.
Now Serhii wants to learn how to perform this trick himself. Help him by writing a program that finds the numerator of the hidden fraction.
Three fractions are given in three separate lines in the format numerator / denominator (p_1 / q_1, , p_2 / q_2), where is replaced by a question mark "?". All numerators and denominators are positive integers not exceeding .
Print the minimal numerator such that p_1 / q_1 < a / b < p_2 / q_2. If no such fraction exists, print "-1".
Example 1
Example 2