This content is archived!
For the 2018-2019 school year, we have switched to using the WLMOJ judge for all MCPT related content. This is an archive of our old website and will not be updated.Problem
On Christmas morning, Matthew and Emily rush down the stairs excited to open their presents. They find N presents, one of which is the biggest present they’ve ever seen! After examining the presents, they find that the presents don’t specify their recipients, which causes them to start fighting over who gets the big present. In order to stop the kids’ fighting, their parents devise a way for the kids to split the presents.
They split the presents as follows: Emily goes first and takes up to M presents for herself. Then Matthew takes up to M presents for himself. The two kids alternate taking up to M presents, however they aren’t allowed to take the big present until all the other presents have been distributed. Furthermore, during each child’s turn, they must take at least one present.
Both Matthew and Emily don’t care about any of the small presents - they only want the big present. If they split the presents optimally, which child is guaranteed to receive the big present?
Input
The first line of input provides the number of test cases, T (1 \leq T \leq 100). T test cases follow. Each test case consists of one line containing integers N, M (1 \leq N, M \leq 1000).
Output
For each test case, your program should output either Emily
or Matthew
, the name of the child who will get the big present.
Sample Input
Sample Output
Explanation for Sample Output
In the first test case, Emily can take one present on her turn, leaving 4 presents in total. Then, whether Matthew takes 1, 2, or 3 presents, Emily can take 3, 2, or 1 presents respectively on the turn after, guaranteeing her the big present.