#include <bits/stdc++.h>
using namespace std;
int T, lc[3000005], rc[3000005], w[3000005], cnt, rt, s[3000005], Q[30], n, m,
    K, a[50005], b[50005], c[50005], d[50005];
struct O {
  int t, l, r;
} e[100005];
bool cmp(O a, O b) { return a.t < b.t; }
void add(int &u, int p, int q, int l, int r, int x) {
  if (!u) u = ++cnt, w[u] = s[u] = lc[u] = rc[u] = 0;
  if (l <= p && q <= r) {
    if (!(s[u] += x))
      w[u] = w[lc[u]] ^ w[rc[u]];
    else
      w[u] = (q ^ p ^ 1) & 1;
    return;
  }
  if (l <= (p + q) / 2) add(lc[u], p, (p + q) / 2, l, r, x);
  if (r > (p + q) / 2) add(rc[u], (p + q) / 2 + 1, q, l, r, x);
  if (!s[u]) w[u] = w[lc[u]] ^ w[rc[u]];
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= m; ++i) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
  sort(e + 1, e + m + m + 1, cmp);
  for (int I = 1, h = 0; I <= K; I <<= 1, ++h) {
    T = cnt = rt = 0;
    for (int i = 1; i <= m; ++i)
      if (a[i] <= c[i] && b[i] <= d[i]) {
        e[++T] = {b[i], a[i], c[i]};
        e[++T] = {d[i] + 1, -a[i], c[i]};
      }
    sort(e + 1, e + T + 1, cmp);
    for (int i = 1; i < T; ++i) {
      if (e[i].l > 0)
        add(rt, 1, n, e[i].l, e[i].r, 1);
      else
        add(rt, 1, n, -e[i].l, e[i].r, -1);
      Q[h] ^= (e[i + 1].t - e[i].t) & 1 & w[rt];
    }
    if (h) Q[h - 1] ^= Q[h];
    for (int i = 1; i <= m; ++i) {
      a[i] = (a[i] + 1) / 2;
      b[i] = (b[i] + 1) / 2;
      c[i] /= 2;
      d[i] /= 2;
    }
    n /= 2;
  }
  for (int I = 1, h = 0; I <= K; I <<= 1, ++h)
    if (Q[h]) {
      puts("Hamed");
      return 0;
    }
  puts("Malek");
  return 0;
}
