#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, c, ty;
} a[100010];
struct Tnode {
  int x, f, tag, ls, rs;
} t[3000000];
int n, m, k, K, ans, rt, tot;
bool cmp(node x, node y) { return x.a < y.a; }
int getfull(int l, int r) {
  int s = 0;
  l--;
  for (int j = 1; j <= k; j <<= 1)
    s |= (((r / j - l / j) - (j * 2 <= k ? (r / j / 2 - l / j / 2) : 0)) & 1) *
         j;
  return s;
}
void update(int n) {
  if (t[n].tag)
    t[n].x = t[n].f;
  else
    t[n].x = t[t[n].ls].x ^ t[t[n].rs].x;
}
void modify(int &n, int l, int r, int L, int R, int k) {
  if (!n) n = ++tot, t[n].f = getfull(l, r);
  if ((L <= l) && (r <= R))
    t[n].tag += k;
  else {
    int mid = (l + r) >> 1;
    if (L <= mid) modify(t[n].ls, l, mid, L, R, k);
    if (mid < R) modify(t[n].rs, mid + 1, r, L, R, k);
  }
  update(n);
}
void work() {
  scanf("%d %d %d", &n, &m, &k);
  for (K = 1; K * 2 <= k; K <<= 1)
    ;
  for (int i = 1, A, B, C, D; i <= m; i++) {
    scanf("%d %d %d %d", &A, &B, &C, &D);
    a[i] = (node){A, B, D, 1}, a[i + m] = (node){C + 1, B, D, -1};
  }
  sort(a + 1, a + 2 * m + 1, cmp);
  for (int i = 1; i <= 2 * m; i++) {
    if (a[i - 1].a != a[i].a) {
      int x = getfull(a[i - 1].a, a[i].a - 1), y = t[rt].x, sx = 0, sy = 0, s;
      for (int j = K; j; j >>= 1) {
        s = -sx * sy, sx += (x & j) > 0, sy += (y & j) > 0, s += sx * sy;
        if (s & 1) ans ^= j;
      }
    }
    modify(rt, 1, n, a[i].b, a[i].c, a[i].ty);
  }
  puts(ans ? "Hamed" : "Malek");
}
int main() {
  work();
  return 0;
}
