#include <bits/stdc++.h>
using namespace std;
int gi() {
  char ch = '!';
  int res = 0, f = 0;
  while (ch < '0' || ch > '9') {
    ch = getchar();
    if (ch == '-') f = 1;
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 2e5 + 100;
int n, m, K, cnt, ans[33], lsh[N], len[N], tag[N << 2], sum[N << 2], mn[N << 2];
struct rect {
  int p, L, R, w;
  friend bool operator<(rect p, rect q) { return p.p < q.p; }
};
vector<rect> vec;
void puttag(int k, int o) { tag[k] += o, mn[k] += o; }
void pushdown(int k) {
  if (tag[k]) puttag((k << 1), tag[k]), puttag((k << 1 | 1), tag[k]);
  tag[k] = 0;
}
void pushup(int k) {
  mn[k] = min(mn[(k << 1)], mn[(k << 1 | 1)]), sum[k] = 0;
  if (mn[k] == mn[(k << 1)]) sum[k] += sum[(k << 1)];
  if (mn[k] == mn[(k << 1 | 1)]) sum[k] += sum[(k << 1 | 1)];
}
void init(int k = 1, int l = 1, int r = cnt - 1) {
  tag[k] = 0;
  if (l == r) {
    mn[k] = 0, sum[k] = len[l];
    return;
  }
  int mid = (l + r) >> 1;
  init((k << 1), l, mid), init((k << 1 | 1), mid + 1, r);
  pushup(k);
}
void modify(int k, int ql, int qr, int o, int l = 1, int r = cnt - 1) {
  if (ql <= l && r <= qr) {
    puttag(k, o);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(k);
  if (ql <= mid) modify((k << 1), ql, qr, o, l, mid);
  if (qr > mid) modify((k << 1 | 1), ql, qr, o, mid + 1, r);
  pushup(k);
}
int main() {
  n = gi(), m = gi(), K = gi();
  for (int i = 1; i <= m; ++i) {
    int x1 = gi(), y1 = gi(), x2 = gi(), y2 = gi();
    vec.push_back((rect){x1, y1, y2 + 1, 1});
    vec.push_back((rect){x2 + 1, y1, y2 + 1, -1});
  }
  int L = 0;
  while (1 << L < K) ++L;
  if (1 << L > K) --L;
  K = 1 << L;
  sort(vec.begin(), vec.end());
  for (int i = 0; i <= L; ++i) {
    int c = (1 << i);
    cnt = 0;
    for (auto t : vec)
      lsh[++cnt] = (t.L + c - 1) / c, lsh[++cnt] = (t.R + c - 1) / c;
    lsh[++cnt] = 0, sort(lsh + 1, lsh + cnt + 1),
    cnt = unique(lsh + 1, lsh + cnt + 1) - lsh - 1;
    for (int j = 1; j < cnt; ++j) len[j] = lsh[j + 1] - lsh[j];
    init();
    for (int l = 0, r, L, R; l < vec.size(); l = r + 1) {
      if (l != 0 && (lsh[cnt] - (mn[1] == 0 ? sum[1] : lsh[cnt])) & 1)
        ans[i] ^= (((vec[l].p - 1) / c - (vec[l - 1].p - 1) / c) & 1);
      r = l - 1;
      while (r + 1 < vec.size() && vec[r + 1].p == vec[l].p) {
        ++r,
            L = lower_bound(lsh + 1, lsh + cnt + 1, (vec[r].L + c - 1) / c) -
                lsh,
            R = lower_bound(lsh + 1, lsh + cnt + 1, (vec[r].R + c - 1) / c) -
                lsh;
        if (L < R) modify(1, L, R - 1, vec[r].w);
      }
    }
  }
  for (int i = 0; i <= L; ++i) {
    ans[i] ^= ans[i + 1];
    if (ans[i]) puts("Hamed"), exit(0);
  }
  puts("Malek");
  return 0;
}
