#include <stdio.h>
#include <string.h>
// Function to determine the winner of the game
char* determineWinner(char* S) {
int p_count = 0, q_count = 0;
// Count the occurrences of 'p' and 'q' in the string
for (int i = 0; S[i] != '\0'; i++) {
if (S[i] == 'p')
p_count++;
else if (S[i] == 'q')
q_count++;
}
// Determine the winner based on the counts
if (p_count > q_count)
return "Roy";
else if (q_count > p_count)
return "Mahfuj";
else
return "Draw";
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
char S[101];
scanf("%s", S);
printf("%s\n", determineWinner(S));
}
return 0;
}