Let’s solve a problem inspired by this sequence of unlikely events: Given the independent probability of each event to happen, choose any subset of elements so that the probability of all them happening is as small as possible. To make the problem interesting, you are not allowed to choose any adjacent events.
Input
Input consists of several cases, each with the number of events n, followed by n simplified fractions ni/di. Assume 1 ≤ n ≤ 200, 2 ≤ di ≤ 6, and 1 ≤ ni < di.
Output
For each case, print the minimum probability of a subset of non-adjacent events, as a fraction with no common factors.
Input
1 3/4 3 1/2 5/6 2/3 5 1/2 3/5 5/6 1/3 1/4 5 5/6 1/3 3/5 4/5 1/5 8 1/6 1/6 1/5 1/6 1/6 1/5 1/5 1/5 7 1/4 1/4 1/4 1/4 1/4 1/4 1/4
Output
3/4 1/3 5/48 1/15 1/900 1/256