#include <bits/stdc++.h>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 1e5 + 5, L = 31;
struct Seg {
  int l, r, x, k;
} p[N];
bool operator<(Seg a, Seg b) { return a.x < b.x; }
int n, m, k, t, f[N << 2], g[N << 2], tag[N << 2], v[N], cnt, ans;
int lg2(int n) { return n ? lg2(n >> 1) + 1 : -1; }
int get(int x, int k) { return ~x ? (((x >> k) + 1) >> 1) & 1 : 0; }
void pusha(int x, int d) { tag[x] += d; }
void pushup(int x, int l, int r) {
  if (!tag[x])
    f[x] = l < r ? f[x << 1] ^ f[x << 1 | 1] : 0;
  else {
    f[x] = 0;
    if (!~g[x]) {
      g[x] = 0;
      for (int i = 0; i <= t; ++i)
        g[x] |= (get(v[r], i) ^ get(v[l - 1], i)) << i;
    }
    f[x] = g[x];
  }
}
void add(int x, int l, int r, int ql, int qr, int d) {
  if (ql <= l && r <= qr) return pusha(x, d), pushup(x, l, r);
  int mid = (l + r) >> 1;
  if (ql <= mid) add(x << 1, l, mid, ql, qr, d);
  if (qr > mid) add(x << 1 | 1, mid + 1, r, ql, qr, d);
  pushup(x, l, r);
}
int main() {
  n = read(), m = read(), k = read(), k = 1 << lg2(k), t = lg2(n),
  memset(g, -1, sizeof(g));
  for (int i = 1; i <= m; ++i) {
    int a = read(), b = read(), c = read(), d = read();
    v[++cnt] = a - 1, p[cnt] = {a - 1, c, b, 1}, v[++cnt] = c,
    p[cnt] = {a - 1, c, d + 1, -1};
  }
  sort(v + 1, v + 1 + cnt), cnt = unique(v + 1, v + 1 + cnt) - v - 1, m <<= 1;
  for (int i = 1; i <= m; ++i)
    p[i].l = lower_bound(v + 1, v + 1 + cnt, p[i].l) - v,
    p[i].r = lower_bound(v + 1, v + 1 + cnt, p[i].r) - v;
  sort(p + 1, p + 1 + m);
  for (int i = 1, w = lg2(k); i <= m; ++i) {
    if (p[i].x != p[i - 1].x) {
      int s = 0, ca = 0, cb = 0;
      for (int a = 0; a <= t; ++a)
        s |= (get(p[i].x - 1, a) ^ get(p[i - 1].x - 1, a)) << a;
      for (int i = t; i >= w; --i) ca ^= s >> i & 1, cb ^= f[1] >> i & 1;
      if (ca & cb) ans ^= k;
      for (int i = w - 1; ~i; --i) {
        ans ^= cb ? (s >> i & 1) << i : 0, ans ^= ca ? (f[1] >> i & 1) << i : 0;
        if ((f[1] & s) >> i & 1) ans ^= 1 << i;
        ca ^= s >> i & 1, cb ^= f[1] >> i & 1;
      }
    }
    add(1, 1, cnt, p[i].l + 1, p[i].r, p[i].k);
  }
  puts(ans ? "Hamed" : "Malek");
  return 0;
}
