Hermione, being the clever girl she is, wants to pick her battles carefully. Each wizard and witch has a fixed power in her eyes. The value of the power of any wizard, she couldn’t determine. But what she does know, is the ratio of power between a few pairs of wizards and/or witches. She is wondering, given the information she has, if it is possible to know that in a battle of one wizard vs another, who will win?
Formally, there are wizards and witches (including Hermione). Each of them has fixed powers, but that value is unknown to Hermione. She does know, however, that the powers are positive and the ratio of and (i.e. ) for pairs of wizards and witches .
Hermione has queries, each of them asks that in a battle of wizard and wizard , is it possible to know who will win given the information she has? If yes, then who wins? Is it a draw instead?
Note that, a wizard will win against another wizard if the former has more power i.e. . And they will draw if they have equal power i.e. .
The first line of input contains an integer denoting the number of test cases.
For each test case, the first line contains three integers .
.
.
lines follow, each containing four integers meaning that the ratio of power between wizards and is (i.e. ). You can safely assume that . Furthermore, the values and will be co-prime to each other i.e. . You can also assume that each of the information regarding the ratio of powers will be consistent throughout a test case. No two unordered pair will be the same in a test case.
and .
and .
Another lines follow, each containing two integers describing the queries. For each of these queries, Hermione wants to know who will win in the battle between wizards and .
For each query, output a string on a line. For a query , you should output —
“win” if wizard will win against .
“lose” if wizard will lose against .
“draw” if the wizards have equal power and will draw.
“unknown” if it cannot be decided who will win or draw, based on the information Hermione has.
Please note that, you should print these strings without the quotes. Refer to the sample I/O for clarity.
Input | Output |
---|---|
2 4 2 3 1 2 2 3 3 2 2 1 1 2 3 1 2 4 2 1 1 1 2 1 1 2 1 | lose win unknown draw |
Explanation for the Sample I/OThe first three lines in output correspond to the queries of test case . The last line corresponds to the query of test case . In test case ,
In test case ,
|