#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, k, len, tot, ans;
struct node {
  int x, l, r, op;
  bool operator<(const node &b) const { return x < b.x; }
} p[N];
struct segtree {
  int ls, rs, sg, val, sum;
} t[N * 30];
int calc(int l, int r) {
  --l;
  int res = 0;
  for (int i = 0; i <= len; ++i) {
    int t = (r >> i) - (l >> i);
    if (i < len) t -= (r >> i + 1) - (l >> i + 1);
    res |= (t & 1) << i;
  }
  return res;
}
void up(int x) {
  if (t[x].val)
    t[x].sum = t[x].sg;
  else
    t[x].sum = t[t[x].ls].sum ^ t[t[x].rs].sum;
}
void modify(int &x, int l, int r, int ql, int qr, int op) {
  if (!x) t[x = ++tot].sg = calc(l, r);
  if (l >= ql && r <= qr) {
    t[x].val += op;
    up(x);
    return;
  }
  int mid = l + r >> 1;
  if (ql <= mid) modify(t[x].ls, l, mid, ql, qr, op);
  if (qr > mid) modify(t[x].rs, mid + 1, r, ql, qr, op);
  up(x);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  while (1 << len <= k) ++len;
  --len;
  for (int i = 1, a, b, c, d; i <= m; ++i) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    p[i] = (node){a, b, d, 1};
    p[i + m] = (node){c + 1, b, d, -1};
  }
  sort(p + 1, p + m + m + 1);
  for (int i = 1, rt = 0; i <= m + m; ++i) {
    modify(rt, 1, n, p[i].l, p[i].r, p[i].op);
    if (i < m + m && p[i].x < p[i + 1].x) {
      int foo = calc(p[i].x, p[i + 1].x - 1), bar = t[rt].sum, x = 0, y = 0,
          lst = 0;
      for (int j = len; ~j; --j) {
        x += foo >> j & 1;
        y += bar >> j & 1;
        ans ^= (x * y - lst & 1) << j;
        lst = x * y;
      }
    }
  }
  puts(ans ? "Hamed" : "Malek");
  return 0;
}
