#include <bits/stdc++.h>
const int maxn = 100005, maxm = 3000005;
inline int read() {
  int sum = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
  return sum;
}
struct node {
  int ls, rs, l, r, sum, lzy;
} T[maxm];
struct Line {
  int x, l, r, d;
} P[maxn];
int N, M, K, lim, cnt, ans, Rt;
void update(int x) {
  if (T[x].lzy)
    T[x].sum = T[x].r ^ T[x].l - 1;
  else
    T[x].sum = T[T[x].ls].sum ^ T[T[x].rs].sum;
}
void Modify(int &x, int l, int r, int L, int R, int k) {
  if (!x) x = ++cnt, T[x].l = l, T[x].r = r;
  if (l == L && r == R) {
    T[x].lzy += k;
    update(x);
    return;
  }
  int mid = l + r >> 1;
  if (R <= mid)
    Modify(T[x].ls, l, mid, L, R, k);
  else if (L > mid)
    Modify(T[x].rs, mid + 1, r, L, R, k);
  else
    Modify(T[x].ls, l, mid, L, mid, k),
        Modify(T[x].rs, mid + 1, r, mid + 1, R, k);
  update(x);
}
void calc(int l, int r) {
  bool x, y;
  for (int i = 0; i < 30; ++i) {
    x = (r ^ l - 1) >> i & 1, y = T[Rt].sum >> i & 1;
    if (x && y) {
      ans ^= ((lim) < (1 << i) ? (lim) : (1 << i));
      if (i) ans ^= ((lim) < (1 << i - 1) ? (lim) : (1 << i - 1));
    }
  }
}
bool cmp(Line a, Line b) { return a.x < b.x; }
int main() {
  N = read();
  M = read();
  K = read();
  lim = 1;
  while (lim <= K) lim <<= 1;
  lim >>= 1;
  for (int xl, yl, xr, yr, i = 1; i <= M; ++i) {
    xl = read();
    yl = read();
    xr = read();
    yr = read();
    P[++cnt] = (Line){xl, yl, yr, 1};
    P[++cnt] = (Line){xr + 1, yl, yr, -1};
  }
  M = cnt;
  cnt = 0;
  std::sort(P + 1, P + M + 1, cmp);
  for (int i = 1; i <= M; ++i) {
    if (i != 1 && P[i].x != P[i - 1].x) calc(P[i - 1].x, P[i].x - 1);
    Modify(Rt, 1, N, P[i].l, P[i].r, P[i].d);
  }
  puts(ans ? "Hamed" : "Malek");
}
