Problems
Bridges
Bridges
In the Lemuria Country there are \textbf{N} islands connected by bridges. Between each two islands with numbers \textbf{i} and \textbf{i+1} (\textbf{1} ≤ \textbf{i} ≤ \textbf{N-1}) there are several parallel bridges. Among these bridges there are \textbf{a_i} stable, and the remaining \textbf{b_i} bridges are unstable. If one passes a stable bridge from island \textbf{i}, he reaches the island \textbf{i+1}. And if he passes an unstable bridge, then just before he reaches an opposite end of the bridge, it breaks (and since it is broken now, he will never consider it in the future), and the traveler falls in the stream, where the flow brings him to the island number \textbf{1}.
We are staying in the island number \textbf{1}. Our goal is to reach the island number \textbf{N}. We will use the following strategy: on each step we randomly select one of the bridges from the current island to the next one which is not yet broken and pass it. It is clear that if \textbf{a_i} > \textbf{0} for all \textbf{i}, then we will achieve our goal sometime.
The length of each bridge is \textbf{1}. Find the average distance we will travel by bridges before we reach the island with number \textbf{N} if we follow the algorithm described above.
\InputFile
The first line of the input contains an integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{1000}). The next \textbf{N-1} lines contain the description of the bridges. The \textbf{i}'th line contains two integers \textbf{a_i} and \textbf{b_i} separated by single space, (\textbf{1} ≤ \textbf{a_i} ≤ \textbf{1000}, \textbf{0} ≤ \textbf{b_i} ≤ \textbf{1000}). The total number of unstable bridges is less than or equal to \textbf{1000}.
\OutputFile
Output should contain one real number - the answer to the problem. Absolute or relative error should be less than \textbf{10^\{-9\}}.
Input example #1
2 1 1
Output example #1
1.5000000000