#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return b < a ? a : b;
}
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0, b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 100007;
struct node {
  int x, l, r, val;
  node(int _x = 0, int _l = 0, int _r = 0, int _val = 0) {
    x = _x, l = _l, r = _r, val = _val;
  }
  inline friend int operator<(node a, node b) { return a.x < b.x; }
} p[_];
int np;
int n, m, K, KK;
inline int lbcnt(int l, int r) {
  l--;
  int sum = 0;
  for (int i = 1; i <= K; i <<= 1)
    sum |= (((r / i - l / i) - ((i + i <= K) ? (r / i / 2 - l / i / 2) : (0))) &
            1) *
           i;
  return sum;
}
struct jt {
  static const int _t = _ * 31;
  struct node {
    int lc, rc, sum, sg, val;
    node(int _lc = 0, int _rc = 0, int _sum = 0, int _sg = 0, int _val = 0) {
      lc = _lc, rc = _rc, sum = _sum, sg = _sg, val = _val;
    }
  } t[_t];
  int tcnt;
  inline void up(int x) {
    if (t[x].val)
      t[x].sum = t[x].sg;
    else
      t[x].sum = t[t[x].lc].sum ^ t[t[x].rc].sum;
  }
  inline void change(int &x, int l, int r, int tl, int tr, int dlt) {
    if (!x) x = ++tcnt, t[x].sg = lbcnt(l, r);
    if (tl <= l && r <= tr) {
      t[x].val += dlt, up(x);
      return;
    }
    int mid = (l + r) >> 1;
    if (tl <= mid) change(t[x].lc, l, mid, tl, tr, dlt);
    if (tr > mid) change(t[x].rc, mid + 1, r, tl, tr, dlt);
    up(x);
  }
  void cls() {
    for (int i = 0; i <= tcnt; i++) t[i] = node();
    tcnt = 0;
  }
  jt() { memset(t, 0, sizeof(t)), tcnt = 0; }
} t;
int rt;
void finder() {
  t.cls(), np = 0, rt = 0;
  n = ty(), m = ty(), K = ty(), KK = 1;
  while (KK <= K) KK <<= 1;
  for (int i = 1; i <= m; i++) {
    int a = ty(), b = ty(), c = ty(), d = ty();
    p[++np] = node(a, b, d, 1), p[++np] = node(c + 1, b, d, -1);
  }
  sort(p + 1, p + np + 1);
  int ans = 0;
  for (int i = 1; i <= np; i++) {
    if (p[i].x != p[i - 1].x) {
      int a = lbcnt(p[i - 1].x, p[i].x - 1), b = t.t[rt].sum;
      long long sum = 0, aa = 0, bb = 0;
      for (int j = KK; j; j >>= 1) {
        sum = -aa * bb, aa += ((a & j) > 0), bb += ((b & j) > 0),
        sum += aa * bb;
        if (sum & 1) ans ^= j;
      }
    }
    t.change(rt, 1, n, p[i].l, p[i].r, p[i].val);
  }
  puts(ans ? "Hamed" : "Malek");
}
int main() {
  finder();
  return 0;
}
