#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
struct Question {
  int x, l, r, dat;
  inline Question(int tmp1 = 0, int tmp2 = 0, int tmp3 = 0, int tmp4 = 0) {
    x = tmp1, l = tmp2, r = tmp3, dat = tmp4;
  }
  inline int operator<(const Question &a) const { return x < a.x; }
} opt[100010];
int k;
inline int lowbit(int l, int r) {
  int res = 0;
  --l;
  for (int i = 1; i <= k; i <<= 1)
    res |= (((r / i - l / i) -
             (((i << 1) <= k) ? (r / (i << 1) - l / (i << 1)) : (0))) &
            1) *
           i;
  return res;
}
struct SegmentTree {
  int tot = 0, rot = 0;
  int L[100010 * 30], R[100010 * 30], tag[100010 * 30], val[100010 * 30],
      low[100010 * 30];
  inline void upd(int k) {
    if (tag[k])
      val[k] = low[k];
    else
      val[k] = val[L[k]] ^ val[R[k]];
  }
  inline void Mod(int &k, int l, int r, int x, int y, int dat) {
    if (y < l || r < x) return;
    if (!k) k = ++tot, low[k] = lowbit(l, r);
    if (x <= l && r <= y) return tag[k] += dat, upd(k);
    Mod(L[k], l, ((l + r) >> 1), x, y, dat),
        Mod(R[k], ((l + r) >> 1) + 1, r, x, y, dat), upd(k);
  }
} T;
int main() {
  int n = read(), m = read(), ans = 0;
  k = read();
  int lim = 1, cnt = 0;
  for (; lim < k; lim <<= 1)
    ;
  while (m--) {
    int xl = read(), yl = read();
    int xr = read(), yr = read();
    opt[++cnt] = Question(xl, yl, yr, 1);
    opt[++cnt] = Question(xr + 1, yl, yr, -1);
  }
  sort(opt + 1, opt + cnt + 1);
  for (int i = 1; i <= cnt; i++) {
    if (opt[i].x != opt[i - 1].x) {
      int x = lowbit(opt[i - 1].x, opt[i].x - 1), y = T.val[T.rot];
      int a = 0, b = 0, sum = 0;
      for (int j = lim; j; j >>= 1) {
        sum = -a * b, a += (x & j) > 0, b += (y & j) > 0, sum += a * b;
        if (sum & 1) ans ^= j;
      }
    }
    T.Mod(T.rot, 1, n, opt[i].l, opt[i].r, opt[i].dat);
  }
  if (ans)
    puts("Hamed");
  else
    puts("Malek");
  return 0;
}
