#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
int n, m, k, i, j, cnt, ans;
struct tt {
  int h, l, r, op;
} a[100005];
bool cmp(tt x, tt y) { return x.h < y.h; }
int tag[2000005], lc[2000005], rc[2000005], res[2000005], rt, tot;
void upd(int x, int l, int r, int y) {
  tag[x] += y;
  if (tag[x])
    res[x] = r ^ (l - 1);
  else
    res[x] = res[lc[x]] ^ res[rc[x]];
}
void update(int &x, int l, int r, int ql, int qr, int y) {
  if (!x) {
    x = ++tot;
  }
  if (ql <= l && r <= qr) {
    upd(x, l, r, y);
    return;
  }
  int mid = (l + r) / 2;
  if (ql <= mid) update(lc[x], l, mid, ql, qr, y);
  if (qr > mid) update(rc[x], mid + 1, r, ql, qr, y);
  if (tag[x])
    res[x] = r ^ (l - 1);
  else
    res[x] = res[lc[x]] ^ res[rc[x]];
}
int gthigh(int x) {
  int k = 0;
  while ((1 << (k + 1)) <= x) k++;
  return k;
}
void solve(int l, int r) {
  int t = res[rt] & (r ^ (l - 1)), i;
  for (((i)) = (0); ((i)) <= (((int)(30)) - 1); ((i))++)
    if ((t >> i) & 1) {
      ans ^= (1 << (min(k, i)));
      if (i) ans ^= (1 << (min(k, i - 1)));
    }
}
int main() {
  read(n);
  read(m);
  read(k);
  k = gthigh(k);
  for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
    int x, y, xx, yy;
    read(x);
    read(y);
    read(xx);
    read(yy);
    a[++cnt] = (tt){x, y, yy, 1};
    a[++cnt] = (tt){xx + 1, y, yy, -1};
  }
  sort(a + 1, a + cnt + 1, cmp);
  for (((i)) = (1); ((i)) <= ((cnt)); ((i))++) {
    if (i && a[i].h != a[i - 1].h) {
      solve(a[i - 1].h, a[i].h - 1);
    }
    update(rt, 1, n, a[i].l, a[i].r, a[i].op);
  }
  if (ans)
    puts("Hamed");
  else
    puts("Malek");
  return 0;
}
