#P6459. [COCI 2006/2007 #5] TENIS

[COCI 2006/2007 #5] TENIS

Problem Description

Two players play a normal tennis match. The match consists of nn rounds, and each round contains 151 \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 66 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 nn 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 nn, meaning there are nn rounds in total.

The next nn lines each contain 151 \sim 5 set results in the form A:B. It is guaranteed that A and B are integers between 0990 \sim 99.

Output Format

Output nn lines in total.

For each round, output da if the result is valid, or output ne if the result is invalid.

sampras agassi
6
6:2 6:4
3:6 7:5 2:6
6:5 7:4
7:6 7:6
6:2 3:6
6:2 1:6 6:8
da
da
ne
da
ne
da
federer roddick
1
2:6 4:6
ne

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n501 \le n \le 50.

Notes

Translated from COCI2006-2007 CONTEST #5 T3 TENIS

Translated by ChatGPT 5