#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct node {
  int x, l, r, d;
  friend bool operator<(node a, node b) { return a.x < b.x; }
} e[maxn];
struct data {
  int ls, rs, w, la, fi;
} tr[maxn * 30];
int n, m, k, K, root, tot = 0;
inline int lowbit(int l, int r) {
  l--;
  int ret = 0;
  for (int i = 1; i <= k; i <<= 1)
    ret |=
        (((r / i - l / i) - (i * 2 <= k ? r / i / 2 - l / i / 2 : 0)) & 1) * i;
  return ret;
}
inline void pushup(int rt) {
  if (tr[rt].la)
    tr[rt].w = tr[rt].fi;
  else
    tr[rt].w = tr[tr[rt].ls].w ^ tr[tr[rt].rs].w;
}
inline void modify(int L, int R, int t, int l, int r, int &rt) {
  if (!rt) rt = ++tot, tr[rt].fi = lowbit(l, r);
  if (L <= l && r <= R) {
    tr[rt].la += t;
    pushup(rt);
    return;
  }
  int mid = (l + r) >> 1;
  if (R <= mid)
    modify(L, R, t, l, mid, tr[rt].ls);
  else if (L > mid)
    modify(L, R, t, mid + 1, r, tr[rt].rs);
  else
    modify(L, R, t, l, mid, tr[rt].ls), modify(L, R, t, mid + 1, r, tr[rt].rs);
  pushup(rt);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (K = 1; K <= k; K <<= 1)
    ;
  int xl, xr, yl, yr, cnt = 0, x, y, sum = 0, ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
    e[++cnt] = (node){xl, yl, yr, 1};
    e[++cnt] = (node){xr + 1, yl, yr, -1};
  }
  sort(e + 1, e + cnt + 1);
  for (int i = 1; i <= cnt; i++) {
    if (e[i].x != e[i - 1].x) {
      x = lowbit(e[i - 1].x, e[i].x - 1);
      y = tr[root].w;
      xl = xr = sum = 0;
      for (int j = K; j; j >>= 1) {
        sum = -xl * xr;
        xl += ((x & j) > 0);
        xr += ((y & j) > 0);
        sum += xl * xr;
        if (sum & 1) ans ^= j;
      }
    }
    modify(e[i].l, e[i].r, e[i].d, 1, n, root);
  }
  if (ans)
    puts("Hamed");
  else
    puts("Malek");
}
