#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e5 + 9;
struct rect {
  int x1, x2, y1, y2;
};
struct sts {
  int x1, x2, y;
  bool ins;
  sts(int _x1, int _x2, int _y, bool _ins) {
    x1 = _x1, x2 = _x2, y = _y, ins = _ins;
  }
};
bool sts_cmp(sts e1, sts e2) {
  if (e1.y != e2.y) return e1.y < e2.y;
  return e1.ins < e2.ins;
}
int n, m, k, p = 1;
rect r[MAX];
vector<sts> e;
map<int, int> xmp;
int sm[4 * MAX], cnt[4 * MAX], add[4 * MAX];
void push(int id) {
  sm[id] += add[id];
  add[2 * id] += add[id];
  add[2 * id + 1] += add[id];
  add[id] = 0;
}
void ra(int id, int lo, int hi, int qlo, int qhi, int a) {
  push(id);
  if (qlo <= lo && hi <= qhi) {
    add[id] += a, push(id);
    return;
  }
  if (qlo > hi || lo > qhi) return;
  int mid = hi + lo >> 1;
  ra(2 * id, lo, mid, qlo, qhi, a);
  ra(2 * id + 1, mid + 1, hi, qlo, qhi, a);
  sm[id] = min(sm[2 * id + 1], sm[2 * id]);
  cnt[id] = (sm[id] == sm[2 * id] ? cnt[2 * id] : 0) +
            (sm[id] == sm[2 * id + 1] ? cnt[2 * id + 1] : 0);
}
bool cal(int t) {
  e.clear(), xmp.clear(), memset(sm, 0, sizeof sm), memset(cnt, 0, sizeof cnt),
      memset(add, 0, sizeof add);
  for (int i = 0; i < m; i++) {
    int nx1 = (r[i].x1 - 1) / t + 1, nx2 = r[i].x2 / t;
    int ny1 = (r[i].y1 - 1) / t + 1, ny2 = r[i].y2 / t;
    if (nx1 > nx2 || ny1 > ny2) continue;
    xmp[nx1] = xmp[nx2] = 1;
    e.push_back(sts(nx1, nx2, ny1, true)),
        e.push_back(sts(nx1, nx2, ny2 + 1, false));
  }
  sort(e.begin(), e.end(), sts_cmp);
  int moo = 0, last = 0, q = 1;
  for (auto it = xmp.begin(); it != xmp.end(); it++) {
    if (it->first % 2 == last % 2)
      moo += 2, it->second = moo;
    else
      it->second = ++moo;
    last = it->first;
  }
  while (q < moo) q *= 2;
  for (int i = q; i <= 2 * q - 1; i++) sm[i] = add[i] = 0, cnt[i] = 1;
  for (int i = q - 1; i > 0; i--)
    sm[i] = add[i] = 0, cnt[i] = cnt[2 * i] + cnt[2 * i + 1];
  bool cur = false;
  for (int i = 0; i < (int)e.size(); i++) {
    if (e[i].ins)
      ra(1, 1, q, xmp[e[i].x1], xmp[e[i].x2], 1);
    else
      ra(1, 1, q, xmp[e[i].x1], xmp[e[i].x2], -1);
    if (i + 1 < (int)e.size() && (e[i + 1].y - e[i].y) % 2 != 0) {
      int l = cnt[1];
      int s = sm[1];
      if (s > 0)
        cur ^= (q & 1);
      else
        cur ^= ((q - l) & 1);
    }
  }
  return cur;
}
bool go() {
  for (int i = 1; i <= p; i *= 2)
    if (cal(i)) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  while (p * 2 <= k) p *= 2;
  for (int i = 0; i < m; i++) cin >> r[i].x1 >> r[i].y1 >> r[i].x2 >> r[i].y2;
  if (go())
    cout << "Malek";
  else
    cout << "Hamed";
}
