The train wheels shrieked as they slowed down, until the whole convoy came to a halt at the station. The doors opened, and a dozen armed men in fedoras and trench coats descended. They spread across the area, checked the surroundings, and one after another all gave a confirmation sign to their colleague that had stayed on the wagon door. After that, he got inside and shortly after came out accompanied by a much larger and wider figure, also cloaked in the same hat and coat style.
The town was sunken in almost complete darkness, except for tiny candle lights that could be seen behind a few scattered houses. The men lit oil lamps and started leading the way which the tall man followed, surrounding him in a way that clearly denoted they were his guard. The night was cold, and the yellowish light illuminated the puffs of white smoke coming from the breathing of the silent group, all exhaling under their coat collars.
After a few minutes they reached a low-floor house, where two men that had advanced the group were stationed, each on one side of the entrance. The door was open. The leader looked at one of them, and the latter nodded, so he knelt slightly to pass below the frame and entered the lodging. It was a large room, there was a table at the end, and a shape was sitting behind it. Another one of his men was standing beside, and when he placed his lamp on the table the shape was illuminated to become a hooded old woman. Her back was bent forward, and she had a deck of cards on her hand. She raised her eyes and looked at the newcomer across flocks of white hair that fell on her wrinkled face.
The newcomer was clearly not used to asking for permission, so he just sat on the chair across her, and said:
“I know you that you have powers, so you will use them for me.”
“It would have sufficed to ask for them, no need to be this rude waking me up so late in the evening…”
“Shut up, old hen!”, he interrupted abruptly; “And do your thing!”
The man standing next to her increased his grip on her shoulder, to which the woman sighed and started shuffling the deck that was in her hands. She drew two of them and placed them on the table: one had three swords across a heart; the other had a drawing of a man sitting on a throne, a roman numeral four. She said:
“The king will come.”
The man in front of her scoffed:
“It seems that has already happened. Go on.”
She took the two cards, placed them back on the deck, and did some more rounds of shuffling. Slowly, she pulled three more cards, laid them on the table and turned them one by one. She flipped a hand holding a wand, next to he same sitting man, and then an angel pouring a liquid from one cup to another. The roman number fourteen was printed at the top of the last card. The woman stood silent for a moment and then said:
“The king will meet a woman.”
The guard initiated a naughty smile, but quickly switched back to a frown when he noticed his leader’s face had turned red. He was slightly elevated from his seat, with his arms open and his hands pushing against the table. He shouted angrily:
“Go on, witch!”
She kept her sight focused on the surface, took back the three cards with a shaking hand and reshuffled one more time. She placed three more cards and started reveling them slowly. The angel and the sitting man were there again. The last card depicted two people holding a cup each. She whispered in a murmur:
“The woman will defeat the king.”
The man stood up fully and pushed the table violently, causing it to turn and the cards to fly and fall on the floor. The surprised guard released her grip on the old lady, in an instant she used to stand up, hit his groin with her knee, and run towards the back of the house. She jumped through a window with unexpected agility and disappeared in the darkness as the man collapsed on the floor with his hands between his legs. The leader stood furious in the middle of the room as the scene unfolded, and when he noticed the woman had escaped he became even more infuriated, kicked his henchman on the side, and started pushing down the shelves full of vases and books that were on the room. A candle fell on the floor and set a curtain on fire. The leader went out as the men that were stationed on the door came in hurriedly and tried to figure out what to do at the sight of that scene of destruction.
Yes, he needed to figure out the correspondence between the cards and the events in his fate. But he had heard enough mumbo-jumbo from that bunch of impostors that he was sure he could crack the code of what the cards were telling him. And whenever he met that woman, it was definitely her who was going to be defeated.
Was the king really damned as foretold by the cards, or had he just been fooled by the psychics?
Input
Input consists of several cases. Each case starts with the number of readings n. Next follow the n readings, each on a line, and consisting of the space-separated drawn cards, a “->”, and the words in the psychic’s interpretation. The clairvoyant can rearrange the words, and also add “a”, “an”, “the” and “will” to facilitate the interpretation (you should ignore those words); all other words (that is, the real words) come from the cards.
You can assume 1 ≤ n ≤ 20. For each line, the cards and real words are all different. Also, each line has the same number of cards and real words, between 1 and 10. Card names consist only on up to 8 digits and uppercase leters. Words consist only on up to 8 lowercase leters. The total number of different cards and real words of each test is the same, and between 1 and 20.
Output
For each case, print “Fooled!” if no assignment of cards to real words can generate the set of readings given by the psychic. Print “Dazed!” if there is more than one valid assignment. If there is exactly one valid assignment, print “Damned!”, followed by the card to word assignments, one per line, and in lexicographical order of the cards.
Hint
The private test cases were generated at random. The expected solution is a backtracking with some reasonable optimizations.
Input
1 I II -> one two 2 I -> one II -> two 3 I -> one II -> two I II -> one two 3 I II -> one two II III -> two three I III -> one three 2 I II -> one two II III -> two three 3 I II -> one two II III -> two three I III -> one two 3 IV 3S -> the king will come 1W IV XIV -> the king will meet a woman XIV IV 2C -> the woman will defeat the king
Output
Dazed! Damned! I -> one II -> two Damned! I -> one II -> two Damned! I -> one II -> two III -> three Damned! I -> one II -> two III -> three Fooled! Damned! 1W -> meet 2C -> defeat 3S -> come IV -> king XIV -> woman