Some time ago, professor Oak bought an old flat that had no gas contract. What follows is a simpliflied model of the nightmare that he had to suffer.

To acquire gas, you need two papers: one from the gas distributor,
and another from the gas marketer.
Initially, you have none of them.
When you try to get a paper from the distributor,
you will get it with probability *p*_{d}.
However, if you already have a paper from the marketer,
you will lose it with probability *q*_{m}
(the distributor will decide that it is not good enough).
Simetrically,
when you try to get a paper from the marketer,
you will get it with probability *p*_{m}.
However, if you already have a paper from the distributor,
you will lose it with probability *q*_{d}.
You spend a whole day every time that you try to get a paper.
You win this stupid game when you first manage to have a valid paper
from both the distributor and the marketer.

Given all this information, and assuming an optimal strategy, what is the expected number of days to get both papers and therefore gas?

**Input**

Input consists of several cases,
each with *p*_{d}, *q*_{m}, *p*_{m} and *q*_{d} in this order.
All the probabilities are real numbers
with at most two digits after the decimal point.
Additionally, *p*_{d} and *p*_{m} are at least 0.1,
and *q*_{m} and *q*_{d} are at most 0.9.

**Output**

For every case, print with four digits after the decimal point the optimal expected number of days to get gas. The input cases have no precision issues.

Public test cases

**Input**

1 0 1 0 1 0 1 0.5 0.23 0.5 0.42 0.9 0.1 0.9 0.1 0.9

**Output**

2.0000 2.0000 20.6156 920.0000

Information

- Author
- Salvador Roura
- Language
- English
- Official solutions
- C++
- User solutions
- C++
- Event
- Catorzè Concurs de Programació de la UPC - Final
- Date
- 2016-09-21