#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, l, r, p;
  node() { x = l = r = p = 0; }
  node(int a, int b, int c, int d) { x = a, l = b, r = c, p = d; }
  inline friend bool operator<(const node &a, const node &b) {
    return a.x < b.x;
  }
};
int n, m, K, q, sh[500500 << 1];
node p[500500 << 1];
inline int highbit(int x) {
  for (int i = 31; ~i; --i)
    if ((x >> i) & 1) return i;
  return -1;
}
int cov[500500 << 3], xsu[500500 << 3];
int gpre(int x) { return x ^ (x >> 1); }
void pushup(int pos, int l, int r) {
  if (cov[pos])
    xsu[pos] = gpre(sh[r]) ^ gpre(sh[l - 1]);
  else if (l == r)
    xsu[pos] = 0;
  else
    xsu[pos] = xsu[(pos << 1)] ^ xsu[(pos << 1 | 1)];
}
void modify(int L, int R, int w, int l, int r, int pos) {
  if (L <= l && r <= R) return cov[pos] += w, pushup(pos, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(L, R, w, l, mid, (pos << 1));
  if (mid < R) modify(L, R, w, mid + 1, r, (pos << 1 | 1));
  return pushup(pos, l, r);
}
int main() {
  cin >> n >> q >> K;
  K = highbit(K), n = 0;
  for (int i = 1, x, y, xx, yy; i <= q; ++i) {
    scanf("%d%d%d%d", &x, &y, &xx, &yy);
    p[++m] = node(x, y, yy, 1);
    p[++m] = node(xx + 1, y, yy, -1);
    sh[++n] = y - 1, sh[++n] = yy;
  }
  sort(sh + 1, sh + n + 1);
  n = unique(sh + 1, sh + n + 1) - (sh + 1);
  sort(p + 1, p + m + 1);
  int ans = 0;
  for (int i = 1, j; i <= m; i = j + 1) {
    int nowy = xsu[1], nowx = gpre(p[i].x - 1) ^ gpre(p[i - 1].x - 1), now = 0;
    for (int k = 30; k > K; --k) {
      if ((nowy >> k) & 1) nowy ^= (1 << k), nowy ^= (1 << K);
      if ((nowx >> k) & 1) nowx ^= (1 << k), nowx ^= (1 << K);
    }
    for (int k = K; k >= 0; --k) {
      if ((nowy >> k) & 1) now ^= 1, nowy ^= (1 << k);
      if ((nowx >> k) & 1) {
        ans ^= nowy;
        if (now) ans ^= 1 << k;
      }
    }
    for (j = i; j < m && p[j + 1].x == p[i].x; ++j)
      ;
    for (int k = i, l, r; k <= j; ++k) {
      l = lower_bound(sh + 1, sh + n + 1, p[k].l - 1) - sh + 1;
      r = lower_bound(sh + 1, sh + n + 1, p[k].r) - sh;
      modify(l, r, p[k].p, 1, n, 1);
    }
  }
  puts(ans ? "Hamed" : "Malek");
  return 0;
}
