P6386 [COCI 2007/2008 #4] VAUVAU
Description
In a small village, the postman, the milkman, and the garbage collector face the same problem every morning: there are two guard dogs in front of House 18. What they do not know is that the dogs’ behavior follows a pattern.
At the start of a day, one dog will be aggressive for $a$ minutes, then calm for $b$ minutes. The other dog will be aggressive for $c$ minutes, then calm for $d$ minutes. Both dogs repeat this behavior endlessly throughout the day.
Given the times when these three people arrive at House 18, determine how many dogs are aggressive at each time.
Input Format
The first line contains four integers $a, b, c, d$, as described in the statement.
The second line contains three integers: the time $p$ when the postman arrives, the time $m$ when the milkman arrives, and the time $g$ when the garbage collector arrives.
Output Format
Output three lines, each containing one string, in order for the postman, milkman, and garbage collector. The string indicates how many dogs are aggressive when they arrive.
- If no dog is aggressive, output `none`.
- If exactly one dog is aggressive, output `one`.
- If both dogs are aggressive, output `both`.
Explanation/Hint
#### Constraints
For all testdata, it is guaranteed that $1 \leq a, b, c, d, p, m, g \lt 10^3$.
#### Notes
**Translated from [COCI2007-2008](https://hsin.hr/coci/archive/2007_2008/) [CONTEST #4](https://hsin.hr/coci/archive/2007_2008/contest4_tasks.pdf) *T1 VAUVAU***。
Translated by ChatGPT 5