Codeforces Round 282 (Div. 1)
E
Sharti
Codeforces
3200
原题
← D→
翻译中…

During the last 24 hours Hamed and Malek spent all their time playing "Sharti". Now they are too exhausted to finish the last round. So they asked you for help to determine the winner of this round.

翻译中…

"Sharti" is played on a $*n* × *n*$ board with some of cells colored white and others colored black. The rows of the board are numbered from top to bottom using number $1$ to $*n*$. Also the columns of the board are numbered from left to right using numbers $1$ to $*n*$. The cell located at the intersection of $*i*$-th row and $*j*$-th column is denoted by $(*i*, *j*)$.

翻译中…

The players alternatively take turns. In each turn the player must choose a square with side-length at most $*k*$ with its lower-right cell painted white. Then the colors of all the cells in this square are inversed (white cells become black and vice-versa). The player who cannot perform a move in his turn loses.

翻译中…

You know Hamed and Malek are very clever and they would have played their best moves at each turn. Knowing this and the fact that Hamed takes the first turn, given the initial board as described in the input, you must determine which one of them will be the winner.

翻译中…

Input

翻译中…

In this problem the initial board is specified as a set of $*m*$ rectangles. All cells that lie inside at least one of these rectangles are colored white and the rest are colored black.

翻译中…

In the first line of input three space-spereated integers $*n*, *m*, *k*$ ($1 ≤ *k* ≤ *n* ≤ 10^{9}$, $1 ≤ *m* ≤ 5·10^{4}$) follow, denoting size of the board, number of rectangles and maximum size of the turn square during the game, respectively.

翻译中…

In $*i*$-th line of the next $*m*$ lines four space-seperated integers $*a*_{*i*}, *b*_{*i*}, *c*_{*i*}, *d*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ *c*_{*i*} ≤ *n*$, $1 ≤ *b*_{*i*} ≤ *d*_{*i*} ≤ *n*$) are given meaning that $*i*$-th rectangle determining the initial board is a rectangle with upper-left cell at $(*a*_{*i*}, *b*_{*i*})$ and lower-right cell at $(*c*_{*i*}, *d*_{*i*})$.

翻译中…

Output

翻译中…

If Hamed wins, print "Hamed", otherwise print "Malek" (without the quotes).

翻译中…

样例

Input #1
5 2 1
1 1 3 3
2 2 4 4
Output #1
Malek
InputCopy OutputCopy
Input #2
12 5 7
3 4 5 6
1 2 1 2
4 5 9 9
8 6 12 10
12 4 12 4
Output #2
Hamed
InputCopy OutputCopy
题目信息
题号
494E
时间限制
5 s
内存限制
256 MB
标签
数据结构
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。