Marut vs Devil in Hunger Games

3.5

199 votes
Ad-Hoc, Basic Programming, Easy
Problem

As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one string cancels out(character gets deleted) one occurrence of same character in another string. Then, points are allocated to them based on their remaining characters of strings. There are some points associated to each character of strings. Total points of any string is calculated by doing sum of points associated to each character. The total points of string M are given to Marut and total points of string D are given to Devil at the end of each round. Total score of an individual is summation of scores of all individual rounds. In the end, whosoever has greater number of points, will win the Hunger Games.

Your task is to find the winner and print his name. Initially, both of them have zero points.

Input:
First line of the input contains 26 space separated integers denoting points associated to each lowercase English alphabets. First integer denotes points associated to 'a' , second integer to 'b' and so on.
Second line contains an integer Q, denoting number of times game is played.
Then, follow 2*Q lines.
For each game, first line contains string M.
second line contains string D.

Output:
Print "Marut" if Marut wins or "Devil" if Devil wins.
If no one wins i.e they both end up with same scores, print "Draw" (without quotes).

Constraints:
1 ≤ Points associated to each character ≤ 100
String M and D contains only lowercase english alphabets.
1 ≤ |M| , |D| ≤ 104
1Q1000
|M| = |D|

Note:
Large Input Files. Use Fast input/output.

Sample Input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
2
abcd
aabb
abc
xyz
Sample Output
Devil
Time Limit: 4
Memory Limit: 256
Source Limit:
Explanation

In the first round, one occurrence of 'a' and 'b' is cancelled out in both strings M and D, so final string of Marut would be cd and final string of Devil would be ab. Total points of string M are 3+4 = 7 and string D are 1+2=3. For this round , Marut gets 7 points and Devil gets 3 points.
In the second round, no character of both the strings are common. Total points of string M are 1+2+3=6 and string D are 24+25+26=75. For this round Marut gets 6 points and Devil gets 75 points.
Total final scores are: Marut has 13 points and Devil has 78 points. Hence Devil won the game.

Editor Image

?