#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
struct event {
  int x, ty, safdasd, y2;
  event() {}
  event(int x, int ty, int safdasd, int y2)
      : x(x), ty(ty), safdasd(safdasd), y2(y2) {}
};
vector<event> evt;
const int N = 101000;
int val[N * 4], ret[N * 4], cov[N * 4], x1[N], safdasd[N], x2[N], y2[N];
vector<int> vy;
int K, m, n;
bool cmp(const event &a, const event &b) { return a.x < b.x; }
void build(int p, int l, int r) {
  if (l == r) {
    val[p] = vy[l] - vy[l - 1];
  } else {
    int md = (l + r) >> 1;
    build(p + p, l, md);
    build(p + p + 1, md + 1, r);
    val[p] = val[p + p] + val[p + p + 1];
  }
}
void cover(int p, int l, int r, int tl, int tr) {
  if (l == tl && r == tr) {
    cov[p]++;
    ret[p] = val[p];
  } else {
    int md = (l + r) >> 1;
    if (tr <= md)
      cover(p + p, l, md, tl, tr);
    else if (tl > md)
      cover(p + p + 1, md + 1, r, tl, tr);
    else
      cover(p + p, l, md, tl, md), cover(p + p + 1, md + 1, r, md + 1, tr);
    if (cov[p] == 0) ret[p] = ret[p + p] + ret[p + p + 1];
  }
}
void revoc(int p, int l, int r, int tl, int tr) {
  if (l == tl && r == tr) {
    cov[p]--;
    if (cov[p] == 0) {
      if (l < r)
        ret[p] = ret[p + p] + ret[p + p + 1];
      else
        ret[p] = 0;
    }
  } else {
    int md = (l + r) >> 1;
    if (tr <= md)
      revoc(p + p, l, md, tl, tr);
    else if (tl > md)
      revoc(p + p + 1, md + 1, r, tl, tr);
    else
      revoc(p + p, l, md, tl, md), revoc(p + p + 1, md + 1, r, md + 1, tr);
    if (cov[p] == 0) ret[p] = ret[p + p] + ret[p + p + 1];
  }
}
long long solve() {
  evt.clear();
  vy.clear();
  for (int i = 0; i < m; i++) {
    if (x1[i] > x2[i] || safdasd[i] > y2[i]) continue;
    evt.push_back(event(x1[i] - 1, 1, safdasd[i] - 1, y2[i]));
    evt.push_back(event(x2[i], -1, safdasd[i] - 1, y2[i]));
    vy.push_back(safdasd[i] - 1);
    vy.push_back(y2[i]);
  }
  sort((vy).begin(), (vy).end());
  vy.erase(unique((vy).begin(), (vy).end()), vy.end());
  n = ((int)(vy).size()) - 1;
  if (n <= 0) return 0;
  sort((evt).begin(), (evt).end(), cmp);
  build(1, 1, n);
  int prex = 0;
  long long ans = 0;
  for (auto p : evt) {
    ans += (long long)(p.x - prex) * ret[1];
    prex = p.x;
    p.safdasd = lower_bound((vy).begin(), (vy).end(), p.safdasd) - vy.begin();
    p.y2 = lower_bound((vy).begin(), (vy).end(), p.y2) - vy.begin();
    if (p.ty == 1) {
      cover(1, 1, n, p.safdasd + 1, p.y2);
    } else {
      revoc(1, 1, n, p.safdasd + 1, p.y2);
    }
  }
  return ans;
}
vector<long long> rr;
int main() {
  scanf("%*d%d%d", &m, &K);
  for (int i = 0; i < m; i++)
    scanf("%d%d%d%d", x1 + i, safdasd + i, x2 + i, y2 + i);
  int k = 1;
  while (k <= K) {
    rr.push_back(solve());
    for (int i = 0; i < m; i++) {
      safdasd[i] = (safdasd[i] + 1) / 2;
      y2[i] /= 2;
      x1[i] = (x1[i] + 1) / 2;
      x2[i] /= 2;
    }
    k *= 2;
  }
  rr.push_back(0);
  for (int i = 0; i < ((int)(rr).size()) - 1; i++)
    if ((rr[i] ^ rr[i + 1]) % 2) {
      puts("Hamed");
      return 0;
    }
  puts("Malek");
}
