#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, m, k, lim = 1, ans, root, tot, cnt;
int ls[3000010], rs[3000010], tag[3000010], sum[3000010], val[3000010];
struct node {
  int x, l, r, v;
} p[100010];
bool cmp(const node &a, const node &b) { return a.x < b.x; }
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;
}
void pushup(int cur, int l, int r) {
  if (tag[cur])
    sum[cur] = val[cur];
  else
    sum[cur] = sum[ls[cur]] ^ sum[rs[cur]];
}
void modify(int L, int R, int l, int r, int v, int &cur) {
  if (!cur) cur = ++tot;
  val[cur] = get(l, r);
  if (L <= l && R >= r) {
    tag[cur] += v, pushup(cur, l, r);
    return;
  }
  if (L <= ((l + r) >> 1)) modify(L, R, l, ((l + r) >> 1), v, ls[cur]);
  if (R > ((l + r) >> 1)) modify(L, R, ((l + r) >> 1) + 1, r, v, rs[cur]);
  pushup(cur, l, r);
}
int main() {
  read(n), read(m), read(k);
  while (lim <= k) lim <<= 1;
  for (int i = 1; i <= m; ++i) {
    int u, d, l, r;
    read(l), read(u), read(r), read(d);
    p[++cnt] = {l, u, d, 1}, p[++cnt] = {r + 1, u, d, -1};
  }
  sort(p + 1, p + cnt + 1, cmp);
  for (int i = 1; i <= cnt; ++i) {
    if (p[i - 1].x != p[i].x) {
      int v1 = sum[root], v2 = get(p[i - 1].x, p[i].x - 1), s1 = 0, s2 = 0;
      for (int j = lim; j; j >>= 1) {
        s1 += ((v1 & j) != 0), s2 += ((v2 & j) != 0);
        if ((s1 * s2) & 1) ans ^= j;
      }
    }
    modify(p[i].l, p[i].r, 1, n, p[i].v, root);
  }
  if (ans)
    puts("Hamed");
  else
    puts("Malek");
  return 0;
}
