#include <stdio.h>
#include <string.h>
int main() {
int T;
scanf("%d", &T);
for (int t = 0; t < T; t++) {
char S[101];
scanf("%s", S);
int p_count = 0, q_count = 0;
// Count the occurrences of 'p' and 'q'
for (int i = 0; i < strlen(S); i++) {
if (S[i] == 'p') {
p_count++;
} else if (S[i] == 'q') {
q_count++;
}
}
if (p_count > q_count) {
printf("Roy\n"); // Roy wins if p_count is greater
} else if (q_count > p_count) {
printf("Mahfuj\n"); // Mahfuj wins if q_count is greater
} else {
printf("Draw\n"); // Draw if both counts are equal
}
}
return 0;
}