# The thirty-five camels P56276

Statement

thehtml

Once, the great Persian mathematician Beremiz Samir (The Man Who Counted) found three men arguing beside a batch of camels. Asked, the older man replied:

“We are brothers. We received, an inheritance, these 35 camels. According to the will of our father, I ‍must get one half, my middle brother one third, and my little brother one ninth. But we do not know how to divide the 35 camels, because the divisions are not exact.”

“It is very simple.”—replied Beremiz. “I will justly make the division if you allow me to add my own camel to the 35 camels of the inheritance.”

And indeed, that way the older brother got 18 camels, which is more than the 17 and a half that he were to receive, the middle one 12, which is more than the 11 and some that he were to receive, and the little one 4, which is more than the 3 and some that he were to receive. Beremiz then continued:

“By this division that has benefited you all, 18 + 12 + 4 = 34 camels have been distributed. Therefore, there are two spare camels. One is the one that I added, that I recover, and the other rightly belongs to me for having solved the difficult problem of the inheritance.”

Input

Input consists of a natural number n, followed by n cases. Each case consists of tree fractions in one line, all made up of natural numbers between 1 and 500, exactly following the format of the sample. Each numerator is strictly smaller than its denominator.

Output

For each case, print a single line. If the given combination of fractions would allow Beremiz to win exactly one camel as explained in the story, print which should be the number of camels of the initial batch. Print “no” otherwise.

Public test cases
• Input

5
1/2 1/3 1/9
1/2 1/3 1/4
1/5 1/10 1/10
1/5 10/50 2/10
1/5 4/15 2/15

Output

35
no
no
4
no

• Information
Author
Language
English
Translator
Original language
Spanish
Other languages
Spanish
Official solutions
C++ Python
User solutions
C++ Python