After Borko's second plan of taking over the village fell through (because Mirko's brother Stanko drank all the water), young Zvonko decided to relax with sports. For this purpose he stocked up on carrot juice and peanuts, and dived onto the couch, ready to watch the next tennis match on television.
While the two players are warming up, their statistics pop up on the screen. Zvonko noticed that the match history of the players contained invalid results. He had a brilliant idea where you write him a program that checks the validity of results, which he will then sell to the record keepers and enjoy a leisurely life.
A tennis match consists of sets, each set consisting of games. The following rules apply:
A match result is valid if a match could have been played by the above rules and ended in the result.
Additionally, if one of the players is Roger Federer (designated as "federer" in the input), then a result in which he has lost a set can't be valid (Zvonko knows Federer is from outer space).
Write a program that checks the validity of all matches between two players.
The first line of input contains the names of the two players separated by a single space. Both names will be strings of at most 20 lowercase letters of the English alphabet. The names will be different.
The second line contains an integer N (1 ≤ N ≤ 50), how many matches the two players have played.
Each of the following N lines contains the result of a single match, composed of the results of a number of sets separated by single spaces. Each match result will contain between 1 and 5 sets.
A set is given in the format "A:B", where A and B are games won by each player. These numbers will be integers between 0 and 99
For each match, in the order they're given in the input, output "da" if the result is valid, or "ne" if it isn't.