#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, h, way;
} d[50005 * 2];
int ans, n, m, zd, ql, qr, qv, limit, tms, k;
int num[50005], tag[50005 * 50], ls[50005 * 50], rs[50005 * 50], sm[50005 * 50],
    val[50005 * 50];
int get(int l, int r) {
  int v = 0;
  for (int i = 1; i <= k; i <<= 1)
    v |= (((r / i - (l - 1) / i) -
           (i * 2 <= k ? r / i / 2 - (l - 1) / i / 2 : 0)) &
          1) *
         i;
  return v;
}
bool cmp(node a, node b) { return a.h < b.h; }
void update(int p) {
  if (tag[p])
    sm[p] = val[p];
  else
    sm[p] = sm[ls[p]] ^ sm[rs[p]];
}
int tot, rt;
void change(int &p, int l, int r) {
  if (!p) p = ++tot;
  val[p] = get(l, r);
  if (ql <= l && r <= qr) {
    tag[p] += qv;
    update(p);
    return;
  }
  int mid = l + r >> 1;
  if (ql <= mid) change(ls[p], l, mid);
  if (qr > mid) change(rs[p], mid + 1, r);
  update(p);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  limit = 1;
  while (limit <= k) limit <<= 1, ++tms;
  for (int a, b, c, cc, i = 1; i <= m; ++i) {
    scanf("%d%d%d%d", &a, &b, &c, &cc);
    d[++zd].l = b;
    d[zd].r = cc;
    d[zd].h = a;
    d[zd].way = 1;
    d[++zd].l = b;
    d[zd].r = cc;
    d[zd].h = c + 1;
    d[zd].way = -1;
  }
  sort(d + 1, d + 1 + zd, cmp);
  for (int i = 1; i <= zd; ++i) {
    if (d[i - 1].h != d[i].h) {
      int v1 = sm[rt], v2 = get(d[i - 1].h, d[i].h - 1), s1 = 0, s2 = 0;
      for (int j = limit, l = tms; j; j >>= 1, --l)
        s1 += ((v1 & j) != 0), s2 += ((v2 & j) != 0), num[l] += s1 * s2;
    }
    ql = d[i].l, qr = d[i].r, qv = d[i].way;
    change(rt, 1, n);
  }
  for (int i = 0, j = 1; i < tms; ++i, j <<= 1)
    if ((num[i] - num[i + 1] & 1)) ans ^= j;
  puts(ans ? "Hamed" : "Malek");
  return 0;
}
