#include <bits/stdc++.h>
using namespace std;
inline char gc(void) {
  static char buf[1048576], *l = buf, *r = buf;
  if (l == r) r = (l = buf) + fread(buf, 1, 1048576, stdin);
  return l == r ? (~0) : *(l++);
}
inline int re() {
  int X = 0;
  char ch = 0;
  while ('0' > ch || ch > '9') ch = gc();
  while ('0' <= ch && ch <= '9') X = (X << 3) + (X << 1) + (ch ^ 48), ch = gc();
  return X;
}
int m, n, K, cn = 0, ans = 0, c[500012 << 2], nu = 0;
struct C {
  int l, r, x, v;
} a[500012 << 1];
inline bool cmp(C x, C y) { return x.x < y.x; }
int s[500012 << 4], d[500012 << 4], ful[500012 << 4];
void build(int p, int l, int r) {
  if (l == r) {
    ful[p] = c[r] ^ (c[r] >> 1) ^ c[l - 1] ^ (c[l - 1] >> 1);
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  ful[p] = ful[p << 1] ^ ful[p << 1 | 1];
}
void change(int p, int l, int r, int L, int R, int v) {
  if ((L <= l) && (r <= R)) {
    d[p] += v;
    s[p] = d[p] ? ful[p] : ((l == r) ? 0 : (s[p << 1] ^ s[p << 1 | 1]));
    return;
  };
  int mid = (l + r) >> 1;
  if (L <= mid) change(p << 1, l, mid, L, R, v);
  if (mid < R) change(p << 1 | 1, mid + 1, r, L, R, v);
  s[p] = d[p] ? ful[p] : (s[p << 1] ^ s[p << 1 | 1]);
}
inline int calc(int l, int r) {
  if (l > r) return 0;
  int v1 = r ^ (r >> 1) ^ (l - 1) ^ ((l - 1) >> 1), v2 = s[1];
  v1 ^= v1 >> 1;
  v1 ^= v1 >> 2;
  v1 ^= v1 >> 4;
  v1 ^= v1 >> 8;
  v1 ^= v1 >> 16;
  v2 ^= v2 >> 1;
  v2 ^= v2 >> 2;
  v2 ^= v2 >> 4;
  v2 ^= v2 >> 8;
  v2 ^= v2 >> 16;
  v1 &= v2;
  return v1 ^ (v1 >> 1);
}
int main() {
  m = re();
  n = re();
  K = re();
  int i, l1, r1, l2, r2, len = 1;
  m = 0;
  while ((len << 1) <= K) ++m, len <<= 1;
  for (i = 1; i <= n; i++) {
    l1 = re();
    l2 = re();
    r1 = re();
    r2 = re();
    a[++cn] = (C){l1, r1, l2, 1};
    a[++cn] = (C){l1, r1, r2 + 1, -1};
  }
  sort(a + 1, a + cn + 1, cmp);
  for (i = 1; i <= cn; i++) c[++nu] = a[i].l - 1, c[++nu] = a[i].r;
  sort(c + 1, c + nu + 1);
  nu = unique(c + 1, c + nu + 1) - c - 1;
  build(1, 1, nu);
  for (i = 1; i <= cn; i++) {
    if (i > 1) ans ^= calc(a[i - 1].x, a[i].x - 1);
    change(1, 1, nu, lower_bound(c + 1, c + nu + 1, a[i].l) - c,
           lower_bound(c + 1, c + nu + 1, a[i].r) - c, a[i].v);
  }
  for (i = 30; i > m; i--)
    if ((ans >> i) & 1) ans ^= (1 << m) | (1 << i);
  printf("%s", ans ? "Hamed" : "Malek");
  return 0;
}
