P6459 [COCI 2006/2007 #5] TENIS

Description

Two players play a normal tennis match. The match consists of $n$ rounds, and each round contains $1 \sim 5$ sets. The result of each set is written as `A:B`, where `A` is the number of games won by the first player, and `B` is the number of games won by the second player. The match follows these rules: - If one player has won at least $6$ games and has won at least two more games than the other player, then he wins this set. - Also, if the results of the first and second sets are both `6:6`, then a final set will be played to decide the winner. - When a player wins two sets, he is the winner of this round, and the round ends. If a round proceeds according to the rules above and can finally end, then we consider this round valid. However, there is one special player, `federer`. He will not lose any set. (Because we know he comes from outer space...) You need to check whether these $n$ rounds are valid.

Input Format

The first line contains two strings separated by a space, representing the two players. The second line contains an integer $n$, meaning there are $n$ rounds in total. The next $n$ lines each contain $1 \sim 5$ set results in the form `A:B`. It is guaranteed that `A` and `B` are integers between $0 \sim 99$.

Output Format

Output $n$ lines in total. For each round, output `da` if the result is valid, or output `ne` if the result is invalid.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, it is guaranteed that $1 \le n \le 50$. #### Notes **Translated from [COCI2006-2007](https://hsin.hr/coci/archive/2006_2007/) [CONTEST #5](https://hsin.hr/coci/archive/2006_2007/contest5_tasks.pdf) *T3 TENIS***。 Translated by ChatGPT 5