406771: GYM102536 J A Cold Macchiato

Memory Limit:256 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. A Cold Macchiatotime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Spies are usually seen with a cocktail or some other booze in hand. Even if you don't actually like cocktails yourself, at the very least you'd have to blend in to find your target in their favorite bar. After all, shady business transactions are usually done in such dark, relaxing, and hidden places. Sneaking something into your target person's drink is something that you, the best spy in the world, have done many times, and you have just been assigned another target to add to your super long long list of successful missions.

Except that this time, your target is an Asian king named Mr. Bin. And Mr. Bin doesn't like cocktails. Instead, after gathering intel, you found out that Mr. Bin has negligible ankles, likes coffee, and has a very adorable cat named Soseol. Your colleagues thought that you were slacking off when they saw you scrolling through Tweetur, but you were actually browsing Mr. Bin's daily posts of himself, his coffee, and his cat at the subtle coffee shop Covert Feline caFe. You were totally doing research and not spending hours looking at Soseol.

You don't know what Mr. Bin did to become a target, but you were told to disguise yourself as a barista at the Covert Feline caFe and put some sugar in Mr. Bin's favorite coffee drink. You don't know why it's sugar specifically since you usually used some other harmful substance in your past missions. Maybe it's to ruin his diet (pure evil). Or maybe he's actually allergic to sugar, who knows?

Sneaking in the sugar is the easy part. The trickier part is preparing the coffee, since you have never prepared coffee before. You don't drink coffee as you never needed the extra caffeine, being the excellent spy that you are. Upon observing the cafe, you noticed that there are three dispensers (cold, neutral, and hot), each giving water at a specified temperature. To prepare Mr. Bin's drink, the water has to be within a certain temperature range, and you achieve this by getting and mixing water from the three dispensers. When you mix water this way, the resulting drink gets the average temperature of the three dispensers, weighted by their respective volumes.

Furthermore, cats usually run around the cafe, causing the dispensers to malfunction. Each dispenser has a chance of malfunctioning, and when it does, it could end up dispensing water with the temperature of the other dispensers instead. At most one dispenser malfunctions.

As you need to be in perfect disguse as a barista, you should be able to know the volume of water that you will get from each dispenser. You must select it in a way that maximizes the probability that the drink ends up with a temperature that is within the acceptable range.

You may get any nonnegative real amount of water (in milliliters) from each dispenser, as long as the total volume is exactly $$$1000$$$ milliliters.

Input

The first line of input contains an integer $$$b$$$, the number of Covert Feline caFe branches that Mr. Bin visits, followed by the descriptions for each branch.

The first line of each branch contains three integers $$$t_1, t_2, t_3$$$ denoting the respective temperatures for the three dispensers (cold, neutral and hot), separated by single spaces.

The second line for the branch contains three fractions denoting the respective probabilities of the three dispensers to malfunction, separated by a space. The $$$i$$$th fraction, $$$m_{i,\text{(n)}}/m_{i,\text{(d)}}$$$, denotes the probability that the $$$i$$$th dispenser malfunctions.

Then three lines follow. Each of these lines contains three probabilities separated by single spaces, expressed as a fraction of two integers. The $$$j$$$th fraction in the $$$i$$$th line, $$$d_{i,j,\text{(n)}}/d_{i,j,\text{(d)}}$$$. represents the probability that the $$$i$$$th dispenser releases water at the temperature of the $$$j$$$th dispenser if the $$$i$$$th dispenser malfunctions.

The next and final line for the branch contains two space-separated integers $$$l$$$ and $$$u$$$, where $$$l$$$ and $$$u$$$ are the lower and upper bounds for the acceptable range of temperatures. The bounds are inclusive.

Note: The temperatures and volumes are given in units used internally by spies. As these are used in the secret formulas for certain secret substances, the actual conversions to common SI metric units are not disclosed publicly.

Each probability is written as x/y where x and y are integers.

Constraints

  • $$$1 \le b \le 1200$$$

  • $$$-273 \le t_1, t_2, t_3, l, u \le 10^6$$$
  • $$$t_1 < t_2 < t_3$$$
  • $$$l \le u$$$

  • $$$0 \le m_{i,\text{(n)}}, d_{i,j,\text{(n)}} \le 10^3$$$ (these are integers)
  • $$$1 \le m_{i,\text{(d)}}, d_{i,j,\text{(d)}} \le 10^3$$$ (these are integers)

  • The sum of all $$$\frac{m_{i,\text{(n)}}}{m_{i,\text{(d)}}}$$$ is $$$1$$$.
  • For each $$$i$$$, the sum of all $$$\frac{d_{i,j,\text{(n)}}}{d_{i,j,\text{(d)}}}$$$ is $$$1$$$.
Output

For each branch, output a line containing a single fraction denoting the maximum probability that the drink is within the allowable temperature range, if the amounts obtained from the dispensers are chosen optimally. Print it as a fraction "x/y" (without the quotes) in lowest terms and with positive denominator. If the probability is $$$0$$$, output "0/1" (without the quotes). If the probability is $$$1$$$, output "1/1" (without the quotes).

ExampleInput
1
37 38 39
1/5 3/5 1/5
1/3 1/3 1/3
1/3 1/3 1/3
1/3 1/3 1/3
36 38
Output
14/15

加入题单

算法标签: