Every electrical appliance (such as a light bulb) has a certain resistance. When an appliance is connected to a given voltage, the higher its resistance, the lower the current flowing through it. Resistance is measured in ohms. To avoid the round-off errors that affect floating-point numbers, we represent each resistance as a rational number (a quotient of positive integers).
There are two basic ways to connect two or more appliances into a configuration: in series (Figure 1) or in parallel (Figure 2).
Two or more configurations can themselves be connected in series or in parallel to build a more complex configuration, and this process of building more complex configurations from existing ones can be repeated any number of times (Figure 3).
In general, a configuration is either a single appliance, or a series connection of two or more configurations, or a parallel connection of two or more configurations.
The resistance of a configuration is computed with the following two rules:
In Figure 1, the resistance is $3/2 + 3/4 + 1/4 = 5/2$ ohms.
In Figure 2, the resistance is $1/(1/(3/2) + 1/(1/2) + 1/(1/4)) = 3/20$ ohms.
In Figure 3, we first compute $1/(1/(1/2) + 1/(2/3)) + 2/5 = 24/35$ and $1/2 + 1/(1/(2/3) + 1/(2/5)) + 3/2 = 9/4$. Adding the reciprocals of these two values and taking the reciprocal of the result gives $72/137$ ohms.
A configuration can be written in text form.
Thus Figures 1, 2, and 3 are written as the following expressions, respectively:
(3/2 & 3/4 & 1/4)
(3/2 | 1/2 | 1/4)
(((1/2 | 2/3) & 2/5) | (1/2 & (2/3 | 2/5) & 3/2))
The input consists of several test cases, one per line. Each line contains a valid expression that defines a configuration according to the rules above. The resistance value of each appliance is a positive rational number in the form NUMERATOR/DENOMINATOR. There is exactly one blank space on each side of every ampersand or vertical bar, and there are no other blank spaces in the expression.
For each test case, print the resistance of the configuration on its own line, in the form NUMERATOR/DENOMINATOR with all common factors of the numerator and denominator cancelled. Do not print any blank spaces.